18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to send email through my script

santosh.kandesantosh.kande Members
edited December 2012 in Sahi - Open Source
Hi all,

function sendEmail($emailSubject, $emailBody) {
var $host = "smtp.gmail.com";
var $port = 465;
var $username = "abcd123@gmail.com";
var $password = "pwdpwd";
var $isSSL = true; // set to true if you use SSL
var $mailer = new Packages.net.sf.sahi.ant.Mailer($host, $port, $username, $password, $isSSL);
var $from = "abcd123@gmail.com";
var $to = "xyz@gmail.com";
$mailer.send($from, $to, $emailSubject, $emailBody);
}


I have added all the jars to sahi class path as well :
SET SAHI_EXT_CLASS_PATH=\SAHIV3-5\extlib\mail\mail.jar;\SAHIV3-5\extlib\mail\activation.jar;\SAHIV3-5\lib\ant-sahi.jar;

But i am getting below error..

TypeError: [JavaPackage net.sf.sahi.ant.Mailer] is not a function, it is objec

Please let me know how to resolve this error..

Thanks in advance..

Answers

  • Hi,

    Please check if you have the Jars added in correct places. You must be having mail.jar in userdata/extlib/mail folder(create one if its not there). Also you should be having ant-sahi.jar in your lib folder at sahi root directory.
    Also you must specify their path in start_dashboard.bat as given in the documentation of Sahi Pro. Now you can send a mail.

    Thanks,
  • How do we attach a file? I tried to read a file and make $emailBody to pass the result of _readFile.
    But this will send the email as text. I wanted to send a html files as an attachment. How can I do this?
Sign In or Register to comment.