Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / October 2005

Tip: Looking for answers? Try searching our database.

newbie Q: adding text to MailItem.Body (plain textl)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
B. - 05 Oct 2005 13:48 GMT
I've just started with learning VBA but I'm just too curious not to ask at
the beginning.
Is it possible to add text to plain e-mail body with some kind of formatting
(rows).
I believe it's easy for HTML body but can't find on the web how to do it
with plain format.
Maybe importing from text file but I would prefer to include the text within
the code.
Thanks in advance
Sue Mosher [MVP-Outlook] - 05 Oct 2005 13:50 GMT
Plain text messages have no formatting. If you want rows, you include a vbCrLf at the end of each line:

strtext = "some text" & vbCrLf & "more text"
myMessage.Body = strText

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> I've just started with learning VBA but I'm just too curious not to ask at
> the beginning.
[quoted text clipped - 5 lines]
> the code.
> Thanks in advance
B. - 05 Oct 2005 14:55 GMT
Great. That's what I needed (rows).
Tnx

I'm just reading your book.
After 50 pages it seems very good.

Plain text messages have no formatting. If you want rows, you include a
vbCrLf at the end of each line:

strtext = "some text" & vbCrLf & "more text"
myMessage.Body = strText

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> I've just started with learning VBA but I'm just too curious not to ask at
> the beginning.
[quoted text clipped - 7 lines]
> the code.
> Thanks in advance
B. - 07 Oct 2005 12:44 GMT
> I've just started with learning VBA but I'm just too curious not to ask at
> the beginning.
[quoted text clipped - 5 lines]
> within the code.
> Thanks in advance

At the end this seems to be the easiest way to create large text e-mail is.

Dim olApp As Outlook.Application
   Dim objMail As Outlook.MailItem
   Dim strtxt As String
   Dim fso, ts

   Set olApp = Outlook.Application
   Set objMail = olApp.CreateItem(olMailItem)
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set ts = fso.OpenTextFile("c:\textfile.txt", 1)
   strText = ts.ReadAll

       With objMail
      'Set body format to Plain
      .BodyFormat = olFormatPlain
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.