Code to send mail with multiple attachments using Outlook.Application Object in QTP
The below function will send mail to recipient and add multiple attachments in the mail through Outlook Object.
call func_SendMailUsingOutlook("aa@abc.com", "test", "body", "c:\bdlog.txt>c:\testlog.txt")
Function func_SendMailUsingOutlook(strRecipient, strSubject, strBody, AddMultipleAttachment)
'''Create an instance of Outlook application Set objol=CreateObject("Outlook.Application")
Set objMail=objol.CreateItem(0)
objMail.to=strRecipient
objMail.Subject=strSubject
objMail.Body=strBody
''Add multiple attachments to mail
strAttachments = split(AddMultipleAttachment,">")
intCount = ubound(strAttachments)
For i = 0 to (intCount)
If (strAttachments(i) <> "") Then
objMail.Attachments.Add(strAttachments(i))
End If
Next
objMail.Send
objol.Quit
Set objMail = Nothing
Set objol = Nothing
End Function
No comments:
Post a Comment