Package de.elo.ix.jscript
Class SendMail
java.lang.Object
de.elo.ix.jscript.SendMail
This class supports functions to send an email.
In order to use this class, the mail server access has to be defined as a JNDI Resource e.g. in the Tomcat configuration file Tomcat/conf/config.xml.
Configure Mail Server Access
The following XML code shows an example for a resource definition.
<Resource name="mail/TestMailSession" auth="Container"
type="jakarta.mail.Session"
mail.smtp.host="192.168.1.11"
mail.user="Fritz"
mail.password="geheim"
mail.port="25"
mail.transport.protocol="smtp"
mail.debug="true"/>
JavaScript Usage Example
function sendMail(ec, args) {
var sendMail = new Packages.de.elo.ix.jscript.SendMail("mail/TestMailSession");
sendMail.subject = "This Testmail costs 100€";
sendMail.TO = ["fritz@maria.com"];
sendMail.body = "Plain text or <h1>HTML formatted text</h1>";
sendMail.attachments = ["C:\\attachment1.txt", "C:\\attachment2.txt"];
sendMail.send();
}
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SendMail
Constructor.- Parameters:
mailResource
- JDNI resource name, that is configured in the context.xml of Tomcat or the context.xml of Indexserver.- Throws:
Exception
-
SendMail
-
-
Method Details
-
setSender
-
getSender
-
setTO
-
getTO
-
setCC
-
getCC
-
setBCC
-
getBCC
-
setSubject
-
getSubject
-
setBody
-
getBody
-
setAttachments
-
getAttachments
-
send
Send the mail.- Throws:
Exception
-