Hello Friends!!
In this post we will quickly see how to send an outlook email.
I know, most of you all know how to send email using QTP, then why this post??
Well, here we will see how to use HTML code to format your email's body i.e. text style, font color, formatting etc. Here we go!!
Dim oOutlook, oEmail, vEmailTo, vEmailCC, vEmailBCC
vEmailTo = "catchall1@email.com" 'replace this with your email id
vEmailCC = "catchall2@email.com"
vEmailBCC = "catchall3@email.com"
vEmailSubject = "Test Email from QTPschool.com"
Set oOutlook = CreateObject("Outlook.Application")
Set oEmail = oOutlook.CreateItem(0)
oEmail.To = vEmailTo
oEmail.CC = vEmailCC
oEmail.BCC = vEmailBCC
oEmail.Subject = vEmailSubject
oEmail.HTMLBody = "<HTML>"&_
"<Body>"&_
"<p Style=""background-color:red""><b>This text is bold and red background</b></p>"&_
"<p><strong>This text is strong</strong></p>"&_
"<p><em>This text is emphasized</em></p>"&_
"<p><Font color=""green""<i>This text is green and italic</Font></i></p>"&_
"<p><Font color=""red"" size = 16><small>This text is red and big!</small></Font></p>"&_
"<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>"&_
"</Body>"&_
"</HTML>"
wait 2
oEmail.Send
wait 2
Set oEmail = Nothing
Set oOutlook = Nothing
'For more details on HTML code, please visit http://www.w3schools.com/html/html_formatting.asp
In case of any queries, please post your comments. Happy QTPing!!
In this post we will quickly see how to send an outlook email.
I know, most of you all know how to send email using QTP, then why this post??
Well, here we will see how to use HTML code to format your email's body i.e. text style, font color, formatting etc. Here we go!!
Dim oOutlook, oEmail, vEmailTo, vEmailCC, vEmailBCC
vEmailTo = "catchall1@email.com" 'replace this with your email id
vEmailCC = "catchall2@email.com"
vEmailBCC = "catchall3@email.com"
vEmailSubject = "Test Email from QTPschool.com"
Set oOutlook = CreateObject("Outlook.Application")
Set oEmail = oOutlook.CreateItem(0)
oEmail.To = vEmailTo
oEmail.CC = vEmailCC
oEmail.BCC = vEmailBCC
oEmail.Subject = vEmailSubject
oEmail.HTMLBody = "<HTML>"&_
"<Body>"&_
"<p Style=""background-color:red""><b>This text is bold and red background</b></p>"&_
"<p><strong>This text is strong</strong></p>"&_
"<p><em>This text is emphasized</em></p>"&_
"<p><Font color=""green""<i>This text is green and italic</Font></i></p>"&_
"<p><Font color=""red"" size = 16><small>This text is red and big!</small></Font></p>"&_
"<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>"&_
"</Body>"&_
"</HTML>"
wait 2
oEmail.Send
wait 2
Set oEmail = Nothing
Set oOutlook = Nothing
'For more details on HTML code, please visit http://www.w3schools.com/html/html_formatting.asp
In case of any queries, please post your comments. Happy QTPing!!