Call AttachHTMLAsMailContent("Team-Picasso-QA123", "shukr02", "alara01", "Automation Completed", "http://result.com")
Function AttachHTMLAsMailContent(sSendTo, sSendToCC, sSendToBCC, sSubject, sHtmlPath)
Dim objOutlook
Dim objOutlookMsg
Dim olMailItem
' Create the Outlook object and the new mail object.
Set objOutlook = CreateObject(Outlook.Application)
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
' Define mail recipients
objOutlookMsg.To = sSendTo
objOutlookMsg.CC = sSendToCC
objOutlookMsg.BCC = sSendToBCC
' Body of the message
With objOutlookMsg
Set fso = CreateObject(Scripting.FileSystemObject)
Set ts = fso.OpenTextFile(sHtmlPath, 1)
strText = ts.ReadAll
.HTMLBody = strText
.Display
End With
' Send the message
objOutlookMsg.Send
Wait (3)
' Release the objects
Set objOutlook = Nothing
Set objOutlookMsg = Nothing
Set objOutlookMsg = Nothing
End Function
No comments:
Post a Comment