www.element4solution.com

e4s.mail
Class E4SendMail

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.mail.E4SendMail

public class E4SendMail
extends E4Object

Send an email.

Example_MailSend.java

Since:
JDK 1.4
See Also:
E4MailSettings, E4ReceiveMail

Field Summary
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4SendMail()
           
E4SendMail(E4ApplObj_Intf applobj)
           
E4SendMail(E4MailSettings_Intf settings)
           
E4SendMail(E4MailSettings_Intf settings, E4ApplObj_Intf applobj)
           
E4SendMail(E4MailSettings_Intf settings, java.lang.String to_email)
           
E4SendMail(E4MailSettings_Intf settings, java.lang.String to_email, E4ApplObj_Intf applobj)
           
E4SendMail(E4MailSettings_Intf settings, java.lang.String to_email, java.lang.String cc_email)
           
E4SendMail(E4MailSettings_Intf settings, java.lang.String to_email, java.lang.String cc_email, E4ApplObj_Intf applobj)
           
E4SendMail(java.lang.String to_email)
           
E4SendMail(java.lang.String to_email, E4ApplObj_Intf applobj)
           
E4SendMail(java.lang.String to_email, java.lang.String cc_email)
           
E4SendMail(java.lang.String to_email, java.lang.String cc_email, E4ApplObj_Intf applobj)
           
 
Method Summary
static java.lang.String _getSVNVersionString()
          Get version info string from subversion.
 void bcc(java.lang.String email)
          Specify or add an address to the recipient list ("bcc") for the message.
 void cc(java.lang.String email)
          Specify or add an address to the recipient list ("cc") for the message.
 java.lang.String getFrom()
          Get the mail from address, this can be either a specified address (setFrom(java.lang.String) or a predefined value in the .ini settings E4MailSettings.getMailFrom().
 java.lang.Exception getLastError()
          If an application object was specified during creation of this object, all results as well as errors are stroed in the database table T_E4S_MAIL_SENT_Sel but no exception is thrown during sending the message.
 java.lang.String[] getTo()
           
static boolean isMailEnabled()
           
 void sendERROR(java.lang.String subj, java.lang.String text, java.lang.Throwable thr)
          Send an email using the specified subject and text, add throwable text and call stack to the mail body.
 boolean sendHTML(E4Label_Intf subj, E4HtmlElement_Intf element, E4ServletImplementation_Intf servlet)
           
 void sendHTML(E4Label_Intf subj, E4HtmlElement_Intf element, java.io.File[] attachment, E4ServletImplementation_Intf servlet)
           
 void sendHTML(E4Label_Intf subj, E4StringBufferHtml element, java.io.File[] attachment, Language language)
           
 boolean sendHTML(java.lang.String subj, E4HtmlElement_Intf element, E4ServletImplementation_Intf servlet)
          Send an email using the specified subject and e4s compatible html content, including no attachments.
 void sendHTML(java.lang.String subj, E4HtmlElement_Intf element, java.io.File[] attachment, E4ServletImplementation_Intf servlet)
           
 void sendHTML(java.lang.String subj, E4StringBufferHtml element, java.io.File[] attachment)
           
 boolean sendHTML(java.lang.String subj, java.lang.String element)
          Send an email using the specified subject and user defined html content, including no attachments.
 boolean sendHTML(java.lang.String subj, java.lang.StringBuffer element)
          Send an email using the specified subject and user defined html content, including no attachments.
 void sendHTML(java.lang.String subject, java.lang.String element, java.io.File[] attachment)
           
 boolean sendPLAIN(Language dest_lang, E4Label_Intf subj, java.lang.String text)
          Send an email using the specified subject and text.
 boolean sendPLAIN(Language dest_lang, E4Label_Intf subj, java.lang.StringBuffer text)
          Send an email using the specified subject and text.
 boolean sendPLAIN(Language dest_lang, E4Label_Intf subj, java.lang.String text, java.io.File attachment)
          Send an email using the specified subject and text but also include a file for attachment.
 boolean sendPLAIN(Language dest_lang, E4Label_Intf subj, java.lang.String text, java.io.File[] attachments)
          Send an email using the specified subject and text but also include a file for attachment.
 boolean sendPLAIN(java.lang.String subj, java.lang.String text)
          Send an email using the specified subject and text.
 boolean sendPLAIN(java.lang.String subj, java.lang.StringBuffer text)
          Send an email using the specified subject and text.
 boolean sendPLAIN(java.lang.String subj, java.lang.String text, java.io.File attachment)
          Send an email using the specified subject and text but also include a file for attachment.
 void setFrom(java.lang.String from)
          Specify the mail from address.
 void to(java.lang.String email)
          Specify or add an address to the recipient list ("to") for the message.
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, finalize, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, toString, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

E4SendMail

public E4SendMail(E4MailSettings_Intf settings)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail()
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(E4MailSettings_Intf settings,
                  E4ApplObj_Intf applobj)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(E4ApplObj_Intf applobj)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(E4MailSettings_Intf settings,
                  java.lang.String to_email)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(java.lang.String to_email)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(E4MailSettings_Intf settings,
                  java.lang.String to_email,
                  E4ApplObj_Intf applobj)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(java.lang.String to_email,
                  E4ApplObj_Intf applobj)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(E4MailSettings_Intf settings,
                  java.lang.String to_email,
                  java.lang.String cc_email)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(java.lang.String to_email,
                  java.lang.String cc_email)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(E4MailSettings_Intf settings,
                  java.lang.String to_email,
                  java.lang.String cc_email,
                  E4ApplObj_Intf applobj)
           throws java.lang.Exception
Throws:
java.lang.Exception

E4SendMail

public E4SendMail(java.lang.String to_email,
                  java.lang.String cc_email,
                  E4ApplObj_Intf applobj)
           throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

to

public void to(java.lang.String email)
Specify or add an address to the recipient list ("to") for the message.

Parameters:
email - the email-address of the recipient
See Also:
cc(String)

cc

public void cc(java.lang.String email)
Specify or add an address to the recipient list ("cc") for the message.

Parameters:
email - the email-address of the cc recipient
See Also:
to(String)

bcc

public void bcc(java.lang.String email)
Specify or add an address to the recipient list ("bcc") for the message.

Parameters:
email - the email-address of the cc recipient
See Also:
to(String)

sendPLAIN

public boolean sendPLAIN(java.lang.String subj,
                         java.lang.String text)
                  throws java.lang.Exception
Send an email using the specified subject and text. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN( String, String, File ), sendPLAIN( String, StringBuffer ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendERROR

public void sendERROR(java.lang.String subj,
                      java.lang.String text,
                      java.lang.Throwable thr)
Send an email using the specified subject and text, add throwable text and call stack to the mail body. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
thr - a throwable to be added
See Also:
sendPLAIN( String, String, File ), sendPLAIN( String, StringBuffer ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendPLAIN

public boolean sendPLAIN(Language dest_lang,
                         E4Label_Intf subj,
                         java.lang.String text)
                  throws java.lang.Exception
Send an email using the specified subject and text. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN( String, String, File ), sendPLAIN( String, StringBuffer ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendPLAIN

public boolean sendPLAIN(java.lang.String subj,
                         java.lang.StringBuffer text)
                  throws java.lang.Exception
Send an email using the specified subject and text. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN( String, String ), sendPLAIN( String, String, File ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendPLAIN

public boolean sendPLAIN(Language dest_lang,
                         E4Label_Intf subj,
                         java.lang.StringBuffer text)
                  throws java.lang.Exception
Send an email using the specified subject and text. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN( String, String ), sendPLAIN( String, String, File ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendPLAIN

public boolean sendPLAIN(java.lang.String subj,
                         java.lang.String text,
                         java.io.File attachment)
                  throws java.lang.Exception
Send an email using the specified subject and text but also include a file for attachment. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
attachment - a file attachment, can be null
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN( String, String ), sendPLAIN( String, String, File[] ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendPLAIN

public boolean sendPLAIN(Language dest_lang,
                         E4Label_Intf subj,
                         java.lang.String text,
                         java.io.File attachment)
                  throws java.lang.Exception
Send an email using the specified subject and text but also include a file for attachment. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
attachment - a file attachment, can be null
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN( String, String ), sendPLAIN( String, String, File[] ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendPLAIN

public boolean sendPLAIN(Language dest_lang,
                         E4Label_Intf subj,
                         java.lang.String text,
                         java.io.File[] attachments)
                  throws java.lang.Exception
Send an email using the specified subject and text but also include a file for attachment. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
text - the body text of the message, can be null
attachments - an array of files for attachments, can be null
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN( String, String ), sendPLAIN( String, String, File ), sendHTML(java.lang.String, e4s.html.E4HtmlElement_Intf, e4s.servlet.E4ServletImplementation_Intf)

sendHTML

public boolean sendHTML(java.lang.String subj,
                        E4HtmlElement_Intf element,
                        E4ServletImplementation_Intf servlet)
                 throws java.lang.Exception
Send an email using the specified subject and e4s compatible html content, including no attachments. When using HTML formatted messages, be careful when using images - you should define images using an absolute URL. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
element - a e4s HTML element, such as e.g. TABLE, BODY
servlet - the servlet's context, E4ModuleImplementation.getServlet()
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN(java.lang.String, java.lang.String), sendHTML( String, String )

sendHTML

public boolean sendHTML(E4Label_Intf subj,
                        E4HtmlElement_Intf element,
                        E4ServletImplementation_Intf servlet)
                 throws java.lang.Exception
Throws:
java.lang.Exception

sendHTML

public boolean sendHTML(java.lang.String subj,
                        java.lang.StringBuffer element)
                 throws java.lang.Exception
Send an email using the specified subject and user defined html content, including no attachments. When using HTML formatted messages, be careful when using images - you should define images using an absolute URL. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
element - a e4s HTML element, such as e.g. TABLE, BODY
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN(java.lang.String, java.lang.String), sendHTML( String, E4HtmlElement_Intf, E4ServletImplementation_Intf )

sendHTML

public boolean sendHTML(java.lang.String subj,
                        java.lang.String element)
                 throws java.lang.Exception
Send an email using the specified subject and user defined html content, including no attachments. When using HTML formatted messages, be careful when using images - you should define images using an absolute URL. The addreses have been specified in the constructor or you use the to(String) or cc(String) methods to specify addresses.

Parameters:
subj - the message subject, can be null
element - a e4s HTML element, such as e.g. TABLE, BODY
Returns:
false if an error occured but errors are supressed because they are written into database table T_E4S_MAIL_SENT_Sel because an E4ApplObj_Intf was specified during instantiation.
Throws:
java.lang.Exception
See Also:
sendPLAIN(java.lang.String, java.lang.String), sendHTML( String, E4HtmlElement_Intf, E4ServletImplementation_Intf )

getFrom

public java.lang.String getFrom()
Get the mail from address, this can be either a specified address (setFrom(java.lang.String) or a predefined value in the .ini settings E4MailSettings.getMailFrom().

Returns:
the from address

setFrom

public void setFrom(java.lang.String from)
Specify the mail from address. If not specified, this address is taken from E4MailSettings.getMailFrom() automatically, so a definition is explicit not required (except in the system .ini file).

Parameters:
from - email address the message is sent from - please note, that depending on the vendor and settings of your email server, it might be restricted to use another from address rather than that one which is associated by the user name and login.
See Also:
E4MailSettings.getMailFrom(), getFrom()

getLastError

public java.lang.Exception getLastError()
If an application object was specified during creation of this object, all results as well as errors are stroed in the database table T_E4S_MAIL_SENT_Sel but no exception is thrown during sending the message. You can get the message here.


isMailEnabled

public static boolean isMailEnabled()

getTo

public java.lang.String[] getTo()

sendHTML

public void sendHTML(E4Label_Intf subj,
                     E4HtmlElement_Intf element,
                     java.io.File[] attachment,
                     E4ServletImplementation_Intf servlet)
              throws java.lang.Exception
Throws:
java.lang.Exception

sendHTML

public void sendHTML(E4Label_Intf subj,
                     E4StringBufferHtml element,
                     java.io.File[] attachment,
                     Language language)
              throws java.lang.Exception
Throws:
java.lang.Exception

sendHTML

public void sendHTML(java.lang.String subj,
                     E4HtmlElement_Intf element,
                     java.io.File[] attachment,
                     E4ServletImplementation_Intf servlet)
              throws java.lang.Exception
Throws:
java.lang.Exception

sendHTML

public void sendHTML(java.lang.String subj,
                     E4StringBufferHtml element,
                     java.io.File[] attachment)
              throws java.lang.Exception
Throws:
java.lang.Exception

sendHTML

public void sendHTML(java.lang.String subject,
                     java.lang.String element,
                     java.io.File[] attachment)
              throws java.lang.Exception
Throws:
java.lang.Exception

_getSVNVersionString

public static java.lang.String _getSVNVersionString()
Get version info string from subversion.

Returns:
the version info string.
See Also:
E4Util.getRevisionCodeFromSVN(Class)

www.element4solution.com