How to send email with attachment from outlook using qtp ?
Text1 ="The information contained in this message " _
& "constitutes privileged and confidential information " _
& "and is intended only for the use of and review by " _
& "the recipient designated above."
Text2= "The information contained in this message " _
& "constitutes privileged and confidential information " _
& "and is intended only for the use of and review by " _
& "the recipient designated above."
'Multiline body
Body= Text1 & vbCrLf & Text2
'path of the file sample.txt to be attached
path="D:\sample.txt"
'Usage of Function "Send_Testresults"
'Multiple email Id can be used with semicolon as Seperator
Send_Testresults"xx@mail.com;yy@abc.com","zz@xyz.com",,"Mail from QTPWorld.com",Body,path
'Function to send email
Function Send_Testresults(sTo,sCC,sBCC,sSubject,sBody,sAttachment)
'Open outlook if Outlook is not open
systemUtil.Run "OUTLOOK.EXE"
wait (10)
'Create Outlook Object
Set oMail = CreateObject("Outlook.Application")
set Sendmail=oMail.CreateItem(0)
Sendmail.To=sTo
Sendmail.CC=sCC
Sendmail.BCC=sBCC
Sendmail.Subject=sSubject
Sendmail.Body=sBody
If (sAttachment <> "") Then
Sendmail.Attachments.Add(sAttachment)
End If
Sendmail.Send
oMail.quit
set Sendmail=Nothing
set oMail=Nothing
End Function
No comments:
Post a Comment