Forum Discussion
marin
12 years agoFrequent Contributor
Hello Javier,
many thanks for your suggestion, much appreciated.
I was hoping that there would be an option to use HTML format within the built in SendMail() function, but apparently there isn't.
I resolved the issue by using CDO. It took me some tome to figure out the correct parameters for Exchange but now I've got this working solution:
Thanks again,
Marin
many thanks for your suggestion, much appreciated.
I was hoping that there would be an option to use HTML format within the built in SendMail() function, but apparently there isn't.
I resolved the issue by using CDO. It took me some tome to figure out the correct parameters for Exchange but now I've got this working solution:
function SendCDOEmail(testResult,result,file)
{
var schema, mConfig, mMessage, mSubject, mBody, mTo;
mBody="Status:\r\n"+ result +"\r\nLog file: <a href =\"" + file + "\">" + file + "</a>";
mTo = "recipient.name@site.com";
mSubject: "Notification: " + testResult;
try
{
schema = "http://schemas.microsoft.com/cdo/configuration/";
mConfig = Sys.OleObject("CDO.Configuration");
mConfig.Fields.Item(schema + "sendusing") = 2; // send using SMTP
mConfig.Fields.Item(schema + "smtpserver") = "123.456.789.001"; // IP address of Exchange server
mConfig.Fields.Item(schema + "smtpserverport") = 25; // Port number
mConfig.Fields.Item(schema + "MailboxURL")= "http://123.456.789.001/Exchange/user.name";
//mConfig.Fields.Item(schema + "sendusername") = "user"; // User name (if needed)
//mConfig.Fields.Item(schema + "sendpassword") = "pwd"; // User password (if needed)
mConfig.Fields.Update();
mMessage = Sys.OleObject("CDO.Message");
mMessage.MimeFormatted = true;
mMessage.Configuration = mConfig;
mMessage.From = "Automated Test <noreply@site.com>";
mMessage.To = mTo;
mMessage.Subject = mSubject;
mMessage.HTMLBody = mBody;
mMessage.Send();
}
catch (exception)
{
Log.Error("E-mail cannot be sent", exception.description);
return false;
}
Log.Message("Message to <" + mTo + "> was successfully sent");
return true;
}
Thanks again,
Marin
Related Content
- 6 years ago
- 3 years ago
Recent Discussions
- 22 hours ago