Hello All
Is there a way to change the text colour in the body of an email that is sent using the SendMail command in Eggplant functional ?
Any help will be much appreciated.
Thanks
Hello All
Is there a way to change the text colour in the body of an email that is sent using the SendMail command in Eggplant functional ?
Any help will be much appreciated.
Thanks
Hi Neel,
The formatting of the email is going to be driven by two factors: how you code the body of your message and whether the message recipient is able to receive HTML-formatted emails. In the code sample below, note two key pieces: the MailType and the additional HTML code embedded in the MailBody. Specifically, in this example, I am using the tag to turn each field header red.
Hope this helps,
Dave
If global ScriptOwner is empty then
put "Eggplant-Automation@mailhost.com" into global ScriptOwner
End If
set MailHost to "smtp.mailhost.com"
set MailAuthentication to "none"
set MailUser to "eggplant@mailhost.com"
set MailPassword to ""
set MailType to "text/html" -- formats email as HTML
put global TestResult.Duration div 60 into TestDurationInMinutes
put global TestResult.Duration rem 60 into TestDurationInSeconds
put format ("%02i",TestDurationInSeconds) into TestDurationInSeconds
put TestDurationInMinutes&":"&TestDurationInSeconds into TestDuration
put global TestResult.LogFile into ScreenError
put "<table>" into MailBody
if Global TotalBatchNumbers not empty
put "<tr><td><span style="color:red">Batch Numbers:</span></td><td>"&&Global TotalBatchNumbers&&"</td></tr>" after MailBody
end if
put "<tr><td><span style="color:red">Duration:</span></td><td>"&&TestDuration&&"</td></tr>" after MailBody
put "<tr><td><span style="color:red">Errors:</span></td><td>"&&global TestResult.Errors&&"</td></tr>" after MailBody
put "<tr><td><span style="color:red">Exceptions:</span></td><td>"&&global TestResult.Exceptions&&"</td></tr>" after MailBody
put "<tr><td><span style="color:red">Log File Location:</span></td><td>"&&global TestResult.LogFile&&"</td></tr>" after MailBody
put "<tr><td><span style="color:red">Run Date/Time:</span></td><td>"&&global TestResult.RunDate&&"</td></tr>" after MailBody
put "<tr><td><span style="color:red">Status:</span></td><td>"&&global TestResult.Status&&Global CriticalError&&"</td></tr>" after MailBody
put "<tr><td><span style="color:red">Warnings:</span></td><td>"&&global TestResult.Warnings&&"</td></tr>" after MailBody
if Global FilesCompleted not empty
put "<tr><td>Files Completed:</td><td>"&&Global FilesCompleted&&"</td></tr>" after MailBody
end if
set Recipient to global ScriptOwner
set Title to "Parameterized email test"
If global TestResult's Status is "success" then
set Title to "Eggplant Manager: SUCCESS - Test:"&&TestName
sendMail (To:Recipient,\
Subject:Title,\
SMTP_HOST:MailHost,\
SMTP_TYPE:MailAuthentication,\
SMTP_USER:MailUser,\
SMTP_PASSWORD:MailPassword,\
"Content-Type":MailType,\
Body: MailBody)
else
set Title to "Eggplant Manager FAILURE - Test"&&TestName
sendMail (To:Recipient,\
Subject:Title,\
SMTP_HOST:MailHost,\
SMTP_TYPE:MailAuthentication,\
SMTP_USER:MailUser,\
SMTP_PASSWORD:MailPassword,\
"Content-Type":MailType,\
Body: MailBody)
End If
Apologies for the late reply. I think I understand what you are saying.
The example is quite useful for what I was looking to do.
Many thanks Dave.