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

  • Thread starter Thread starter B.
  • Start date Start date
B

B.

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
 
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

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
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

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B. said:
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

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
 
Back
Top