How do I append text to the body of a email?

B

Beginner

Hello,
I am new to VBA and object model programming with OutLook. Can someone
assist me in developing VBA for OutLook that add text to the body of the
email message without deleting what is already their?

The simple code below erases the current text and add the text I have
assigned to be put into the body. HELP....

Sub AddLinks()
Dim MyItem As MailItem
Dim MyAtt As Attachment
Const dPath = "<file://d:\>"
Set SelectedItems = ActiveExplorer.Selection
For Each MyItem In SelectedItems
MyItem.Body = dPath
MyItem.Save
Next
MsgBox "Processing Completed!"
End Sub
 
S

Sue Mosher [MVP-Outlook]

This is the syntax for appending text to a variable:

strMyText = strMyText & vbCrLf & "another line of text"

The & operator is used to concatenate (join together) one string with another. vbCrLf is an intrinsic constant that represents the carriage return/line feed characters.

So, if you want to append text to MyItem.Body, the structure of the statement would be identical to that above:

MyItem.Body = MyItem.Body & vbCrLf & dPath

Or, don't include the vbCrLf if you don't need dPath on its own line.

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

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Beginner

Sue,
The statement correction you added to my VBA worked, Thanks for your
assistance.

Beginner :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top