Formatting of outlook email body that is created with Access.

G

Guest

A module is created with following code (Using Microsoft Outlook Object
Library 10):


Sub SendMessage(MessageBody As String)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("rse022")
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("rse022")
objOutlookRecip.Type = olCC

' Set the Subject, Body, and Importance of the message.
.Subject = "Message subject"
.Body = (MessageBody)

.Importance = olImportanceHigh 'High importance
.BodyFormat = olFormatPlain

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
objOutlookMsg.Display

End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub

The string MessageBody is thus inserted in the email body. Note that
the message must be in plaint text because it feeds an automated
system. Which characters to use or how to add new lines in the body of
the new e-mail message instead of one stream of characters?
 

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