G
Guest
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
Therefore the string MessageBody is 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?
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
Therefore the string MessageBody is 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?