QTP/UFT support tip: How to send and email by code using outlook object
You can create an Outlook object by code and use it to send emails.
' Create the Outlook object and the new mail object.
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
' Define mail recipients
objOutlookMsg.To = "email@example.com"
objOutlookMsg.CC = "firstname.lastname@example.org"
objOutlookMsg.BCC = "email@example.com"
' Define a file for attachment
doc = "C:\temp\test.xls"
' Body of the message
objOutlookMsg.Subject = "Subject sample"
objOutlookMsg.Body = "This is a test"
' Add the attachment to the email
' Display the email
' Send the message
' Release the objects
set objOutlook = nothing
set objOutlookMsg = nothing
If you find that this or any post resolves your issue, mark it as an accepted solution.
Note: The Opinions expressed in my post are mine alone, and do not reflect the opinions of my employer. No warranties express or implied for any answered posted.