This post explain how to send e-mail using microsoft outlook object with or without any attachments. In the next article we will explain how to read information from an e-mail message.
''Function Description - This function sends a mail to end user
'' Arguments - SendtoUser - Mail will be send to user mentioned in send to
''Subject - Subject of the mail
''Body - Text of the mail
''Attachment - Path of attachment to send e-mail
SendMailUsingOutlook "SendToUser@test.com; testZ@test.com"," Subject", "Body", ""
Function SendMailUsingOutlook(SendToUser, Subject, Body, Attachment)
'' create an object of outlook application and creating a new e-mail object
Set objOutlook=CreateObject("Outlook.Application")
Set objMail=objOutlook.CreateItem(0)
'' Provide details of the mail object
objMail.to=SendToUser
objMail.Subject=Subject
objMail.Body=Body
'' attach a file with the e-mail, provide path of the attachment in the folder
If (Attachment <> "") Then
objMail.Attachments.Add(Attachment)
End If
'' Send the e-mail
objMail.Send
'' close the instance of Outlook application object
objOutlook.Quit
''release the object created Set objMail = Nothing
Set objOutlook = Nothing
End Function
very helpful post. Thanks
ReplyDelete