Send Email

Could someone guide me with my problem.
I cannot send email, its shows

Error Running Script Command:

sendmail Error - sendmail Failed (see console for details).

SendMail (to:"myemail@gmail.com", subject:“testsubject”, message:“testmessage”)

There are a number of parameters that you may need to add for your script to communicate with your company’s mail server. My script is a bit more complicated, but hopefully, it will help you.

//Sends an email from within a script and closes

If global ScriptOwner is empty then
put “invalidemail@gmail.com” into global ScriptOwner //Replace generic recipient email with a real one.
End If

set MailHost to “smtp.mydomain.com” //Replace generic SMTP address with the actual one.
set MailAuthentication to “none"
set MailUser to “invalidemail@gmail.com” //Replace generic sender email with a real one.
set MailPassword to “myemailpassword” //Replace with sender’s email password. If you choose the encrypt this password see http://docs.testplant.com/ePF/SenseTalk/stk-encrypting-text.htm for more information.
set MailType to “text/html” //Forces email to accept HTML tags in the email body.
put global TestResult.Duration div 60 into TestDurationInMinutes //Test results are reported in seconds. This equation calculates the time in minutes.
put global TestResult.Duration rem 60 into TestDurationInSeconds //This equation calculates the number of seconds remaining after dividing by 60.
put format (”%02i",TestDurationInSeconds) into TestDurationInSeconds //This forces a leading 0 for single-digit seconds.
put TestDurationInMinutes&":"&TestDurationInSeconds into TestDuration //This concatenates minutes with seconds with a colon between.
put global TestResult.LogFile into ScreenError //This attaches the log file to the email.
replace “logfile.txt” with “screen_error.png” in ScreenError //This substitutes the error screenshot for a second instance of the log file.

//Including HTML tags in the mail body allows you to create a table in the body of the email message.
put “” into MailBody
put “
" after MailBody
put “
" after MailBody
put “
" after MailBody
put “
" after MailBody
put “
" after MailBody
put “
" after MailBody
put “
" after MailBody



set Recipient to global ScriptOwner //References the recipient’s email from above.
set Title to “Parameterized email test” //Creates a generic subject line to test whether an email was generated outside of a script run.

If global TestResult’s Status is “success” then
set Title to “SUCCESS - Test:”&&global TestName //Concatenates the script status (Success or Fail) with the test name from the Master Script
sendMail (To:Recipient,</div>
Subject:Title,</div>
SMTP_HOST:MailHost,</div>
SMTP_TYPE:MailAuthentication,</div>
SMTP_USER:MailUser,</div>
SMTP_PASSWORD:MailPassword,</div>
“Content-Type”:MailType,</div>
Body: MailBody,</div>
Attachment: global TestResult.LogFile)
else
set Title to “FAILURE - Test”&&global TestName
sendMail (To:Recipient,</div>
Subject:Title,</div>
SMTP_HOST:MailHost,</div>
SMTP_TYPE:MailAuthentication,</div>
SMTP_USER:MailUser,</div>
SMTP_PASSWORD:MailPassword,</div>
“Content-Type”:MailType,</div>
Body: MailBody,</div>
Attachment: (ScreenError,global TestResult.LogFile))
End If


Duration: ”&&TestDuration&&"
Errors: ”&&global TestResult.Errors&&"
Exceptions: ”&&global TestResult.Exceptions&&"
Log File Location: ”&&global TestResult.LogFile&&"
Run Date/Time: ”&&global TestResult.RunDate&&"
Status: ”&&global TestResult.Status&&"
Warnings: ”&&global TestResult.Warnings&&"