Forum Discussion
- New2APIFrequent Contributor
Hi Charles, I am using ant mail via groovy.
you would need to download following jars and copy it to ReadyAPI/Lib folder.
ant.jar
ant-javamail.jar
ant-launcher.jar
Also you will need to provide SMTP gateway config sucha as email host, port etc.
Below is my script to send an html report as an attachment.
import org.apache.tools.ant.* //preparing an email notification def ReportDir = context.expand ('${#Project#TestReportPath}') def emailHost = context.expand ('${#Global#emailHost}') def fromEmail = context.expand ('${#Project#FromAddress}') def toEmail = context.expand ('${#Project#ToAddress}') def ccEmail = context.expand ('${#Project#CcAddress}') //Sending an email notification def ant = new AntBuilder() ant.mail(mailhost:"${emailHost}", messagemimetype:'text/html', subject:"TestReport: APIs Functional tests", tolist:toEmail, cclist:ccEmail){ from(address:"${fromEmail}") message("Please find the attachment for API Functional Test Report.") attachments(){ fileset(dir:"${ReportDir}"){ include(name:"TestReport-APIFunctionalTests.html") } } }
hope this helps!
Best.