Showing posts with label How to send Email using QTP from Microsoft Outlook. Show all posts
Showing posts with label How to send Email using QTP from Microsoft Outlook. Show all posts

16 Jan 2013

How to send Email using QTP from Microsoft Outlook


 How to send Email using QTP from Microsoft Outlook

'Create an object of type Outlook
Set objOutlook = CreateObject("Outlook.Application")
Set myMail = objOutlook.CreateItem(0)

'Set the email properties
myMail.To = "some_mail_id@gmail.com"
myMail.CC = "some_mail_id_2@gmail.com; some_other_mail@yahoo.com" 'Sending mails to multiple ids
myMail.BCC = "" 'If BCC is not required, then this line can be omitted
myMail.Subject = "Sending mail from MS Outlook using QTP"
myMail.Body= "Test Mail Contents"
myMail.Attachments.Add("D:\Attachment.txt") 'Path of the file to be attached

'Send the mail
myMail.Send
Wait(3)

'Clear object reference
Set myMail = Nothing
Set objOutlook = Nothing