cancel
Showing results for 
Search instead for 
Did you mean: 

using SendEmail function

SOLVED
Occasional Contributor

using SendEmail function

I  am able to build and send an email in TestCoomplete using the SendEmail function but it appears that the only type of email is Plain Text. Is there a way to create html emails so I can embed hyperlinks in the body?

1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: using SendEmail function

In the Help Topic, "Sending Email From Scripts", there are three sections. I was able to resolve my problem by using the third option "Via Microsoft Outlook" I have to be sure to close my Outlook session before I leave each evening but my script can build an HTML body and then send it using code similar to the following example.

 

dim outlook
Set outlook = Sys.OleObject("Outlook.Application")
dim body
body = "<html xmlns:v=""urn:schemas-microsoft-com:vml"" xmlnsSmiley Surprised=""urn:schemas-microsoft-comSmiley SurprisedfficeSmiley Surprisedffice"" xmlns:w=""urn:schemas-microsoft-comSmiley Surprisedffice:word"" xmlns:m=""http://schemas.microsoft.com/office/2004/12/omml"" xmlns=""http://www.w3.org/TR/REC-html40"">"
body = body + "<head>"
body = body + "<META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=us-ascii"">"
body = body + "<meta name=Generator content=""Microsoft Word 15 (filtered medium)"">"
body = body + "</head>"
body = body + "<body lang=EN-US link=""#0563C1"" vlink=""#954F72"">"
body = body + "<div>"
body = body + "<....a lot more html tags including  <a href=""file://filename.ext"">Link Text</a>.....>"
body = body + "</div></body></html>"
Dim mi
Set mi = outlook.CreateItem(0)
mi.BodyFormat = olFormatHTML
mi.Subject = "Test Results"
mi.HTMLBody = body
mi.To = "recipients.name@companyname.com"
mi.Send
outlook.Quit

View solution in original post

4 REPLIES 4
Occasional Contributor

Re: using SendEmail function

I finally figured this out on my own. 

Community Manager

Re: using SendEmail function

Hi @GradyJr,

 

It's great to hear the issue was resolved. Could you please share the solution with us? It will help community members in the future.

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!
Occasional Contributor

Re: using SendEmail function

In the Help Topic, "Sending Email From Scripts", there are three sections. I was able to resolve my problem by using the third option "Via Microsoft Outlook" I have to be sure to close my Outlook session before I leave each evening but my script can build an HTML body and then send it using code similar to the following example.

 

dim outlook
Set outlook = Sys.OleObject("Outlook.Application")
dim body
body = "<html xmlns:v=""urn:schemas-microsoft-com:vml"" xmlnsSmiley Surprised=""urn:schemas-microsoft-comSmiley SurprisedfficeSmiley Surprisedffice"" xmlns:w=""urn:schemas-microsoft-comSmiley Surprisedffice:word"" xmlns:m=""http://schemas.microsoft.com/office/2004/12/omml"" xmlns=""http://www.w3.org/TR/REC-html40"">"
body = body + "<head>"
body = body + "<META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=us-ascii"">"
body = body + "<meta name=Generator content=""Microsoft Word 15 (filtered medium)"">"
body = body + "</head>"
body = body + "<body lang=EN-US link=""#0563C1"" vlink=""#954F72"">"
body = body + "<div>"
body = body + "<....a lot more html tags including  <a href=""file://filename.ext"">Link Text</a>.....>"
body = body + "</div></body></html>"
Dim mi
Set mi = outlook.CreateItem(0)
mi.BodyFormat = olFormatHTML
mi.Subject = "Test Results"
mi.HTMLBody = body
mi.To = "recipients.name@companyname.com"
mi.Send
outlook.Quit

View solution in original post

Community Manager

Re: using SendEmail function

Happy to hear that the issue was resolved!

Happy testing Smiley Happy

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!