cancel
Showing results for 
Search instead for 
Did you mean: 

using SendEmail function

SOLVED
Highlighted
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
Highlighted
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"" xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:w=""urn:schemas-microsoft-com:office: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
Highlighted
Contributor

Re: using SendEmail function

I finally figured this out on my own. 

Highlighted
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

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
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"" xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:w=""urn:schemas-microsoft-com:office: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

Highlighted
Community Manager

Re: using SendEmail function

Happy to hear that the issue was resolved!

Happy testing 🙂

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

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare images using the Region Checkpoint

See replies!

Converting UTC TimeDate in an Excel file

See replies!

Compare HTML table with Excel file and correct data in Excel file

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!
Top Kudoed Authors