Class SendMail

java.lang.Object
de.elo.ix.jscript.SendMail

public class SendMail extends Object
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 Details

    • SendMail

      public SendMail(String mailResource) throws Exception
      Constructor.
      Parameters:
      mailResource - JDNI resource name, that is configured in the context.xml of Tomcat or the context.xml of Indexserver.
      Throws:
      Exception
    • SendMail

      public SendMail(ISendMailHandler handler)
  • Method Details

    • setSender

      public void setSender(String sender)
    • getSender

      public String getSender()
    • setTO

      public void setTO(Object mailTo)
    • getTO

      public Object getTO()
    • setCC

      public void setCC(Object mailTo)
    • getCC

      public Object getCC()
    • setBCC

      public void setBCC(Object mailTo)
    • getBCC

      public Object getBCC()
    • setSubject

      public void setSubject(String subject)
    • getSubject

      public String getSubject()
    • setBody

      public void setBody(String text)
    • getBody

      public String getBody()
    • setAttachments

      public void setAttachments(Object v)
    • getAttachments

      public Object getAttachments()
    • send

      public void send() throws Exception
      Send the mail.
      Throws:
      Exception