Hi All,
I have a send email script that will emails the test results with the attachment (.mht) through zip file
I want to have the body of the message with the below information:
Test : Test project name
Result: Success or Error
Test started: 01/01/2016 12:01:00 AM
Test stopped: 01/01/2016 12:01:00 AM
Test duration: 1 m 5 s
Details:
Total number of project test items: 10
Executed project test items: 10
Project Test Item Results
Passed: 10, including 0 warning(s)
Failed: 0
Please advise on how to have this info in the emails so that it wont be necassary to open the .mht attachment every time
Thanks in Advance!
-----------------------------------------------------------------------------------
/***** HERE IS THE SCRIPT I AM USING ****/
var message = "Attached Test Results ";
function SendResults()
{
var ArchivePath = ""; //Project.ConfigPath + "Log\\TestResults.zip";
aqFileSystem.DeleteFolder("c:\\results\\testresults\\", true);//results /* results directory*/
ArchivePath = "c:\\results\\testresults\\TestResults.mht";
Log.SaveResultsAs(ArchivePath,2 , false);
var fileList = slPacker.GetFileListFromFolder("c:\\results\\testresults\\");
slPacker.Pack(fileList, "c:\\results\\testresults\\", "c:\\results\\testresults\\TestResults.zip");
//slPacker.PackCurrentTest(ArchivePath);
SendEmail("from@gmail.com", "to@gmail.com", "Notification - TestResults", message,
"c:\\results\\testresults\\TestResults.zip");
}
function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
{
var smtpServer = "smtp.gmail.com";
var smtpPort = 465;
var userLogin = "username";
var userPassword = "password";
var autentificationType = 1;
var connectionTimeout = 60;
var useSSL = true;
try {
var schema = "http://schemas.microsoft.com/cdo/configuration/";
var mConfig = Sys.OleObject("CDO.Configuration");
mConfig.Fields.Item(schema + "sendusing") = 2; // cdoSendUsingPort
mConfig.Fields.Item(schema + "smtpserver") = smtpServer;
mConfig.Fields.Item(schema + "smtpserverport") = smtpPort;
mConfig.Fields.Item(schema + "sendusername") = userLogin;
mConfig.Fields.Item(schema + "sendpassword") = userPassword;
mConfig.Fields.Item(schema + "smtpauthenticate") = autentificationType;
mConfig.Fields.Item(schema + "smtpusessl") = useSSL;
mConfig.Fields.Item(schema + "smtpconnectiontimeout") =connectionTimeout;
mConfig.Fields.Update();
var mMessage = Sys.OleObject("CDO.Message");
mMessage.Configuration = mConfig;
mMessage.From = mFrom;
mMessage.To = mTo;
mMessage.Subject = mSubject;
mMessage.HTMLBody = mBody;
//if(0 < mAttachment.length) {
mMessage.AddAttachment(mAttachment);
//}
mMessage.Send();
}
catch(exception) {
Log.Error("E-mail cannot be sent", exception.description);
return false;
}
Log.Message("TestResults to <" + mTo + "> was successfully sent");
return true;
}
↧
send emails - body of the message
↧