Expresso 5-6

com.jcorporate.expresso.core.misc
Class EMailSender

java.lang.Object
  extended bycom.jcorporate.expresso.core.misc.EMailSender

public class EMailSender
extends Object

EMailSender is a class that hides the details of sending email through an SMTP server using the JavaMail API and the Java Activation framework (JAF). This class logs using the log4j category "expresso.core.misc.EMailSender" (info, error, debug) This class uses a DB-context property, mailDebug=Y to dump SMTP debug on the console

default number of retries = 0;

Creation date: (2/6/01 2:09:18 PM)

Author:
Shash Chatterjee

Field Summary
protected  List attachments
           
protected  List dataSourceAttachments
           
protected  String dbName
           
protected  String from
           
protected  String host
           
protected  boolean htmlFormat
           
protected  String password
           
protected  String personal
           
protected  String subject
           
protected  String text
           
protected  String to
           
protected  String user
           
 
Constructor Summary
EMailSender()
          EMailSender constructor
 
Method Summary
 void addDataSourceAttachment(ByteArrayDataSource dataSource)
          This method adds an attachment to the email to be sent.
 void addDataSourceAttachments(List dataSourceList)
          This method accepts a list of byte array data source collection to be sent as attachments.
 void addFileAttachment(String name)
          This method adds an attachment to the email to be sent.
 void addFileAttachments(Vector fileNames)
          This method provides a Vector of String names of files to be sent as attachments
 String getDBName()
          This method returns the name of the DB context, either preset by the caller, or "default" if not set.
 String getPersonal()
          This method sets the address to be used in the From header
 void send()
          This method does all the dirty work of actually sending the email.
 void send(String to, String subject, String text)
          This is a convinience method to wrap the send() method.
 void setConnectRetryDelay(long connectRetryDelay)
          Sets the connectRetryDelay.
 void setDBName(String newDBName)
          This method sets the DB context name, used for looking up several Setup parameters
 void setEmailHtmlFormat()
          Tells the EMail sender to send HTML mail only
 void setFromAddress(String from)
          This method sets the address to be used in the From header
 void setMaxConnectRetries(int maxConnectRetries)
          Sets the maxConnectRetries.
 void setPersonal(String personal)
          This method sets the address to be used in the From header
 void setSMTPHost(String host)
          This method sets the name of the SMTP server to use
 void setSMTPPassword(String password)
          This method sets the SMTP password to use for authentication
 void setSMTPUser(String user)
          This method sets the username to use for SMTP authentication
 void setSubject(String subject)
          This method sets the value to use for the Subject header
 void setText(String text)
          Thiis method sets the content string of the email message
 void setToAddress(String to)
          This method sets the address to be used in the To header
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

to

protected String to

from

protected String from

personal

protected String personal

host

protected String host

user

protected String user

password

protected String password

subject

protected String subject

text

protected String text

dbName

protected String dbName

attachments

protected List attachments

dataSourceAttachments

protected List dataSourceAttachments

htmlFormat

protected boolean htmlFormat
Constructor Detail

EMailSender

public EMailSender()
EMailSender constructor

Method Detail

addFileAttachment

public void addFileAttachment(String name)
This method adds an attachment to the email to be sent. Multiple calls can be made to this method to add multiple attachments

Parameters:
name - java.lang.String The fully-qualified name of a file to send as attachment.

addFileAttachments

public void addFileAttachments(Vector fileNames)
This method provides a Vector of String names of files to be sent as attachments

Parameters:
fileNames - java.util.Vector Vector of fully-qualified file-names (String)

addDataSourceAttachment

public void addDataSourceAttachment(ByteArrayDataSource dataSource)
This method adds an attachment to the email to be sent. Multiple calls can be made to this method to add multiple attachments

Parameters:
dataSource - byte array data source object that represents an virtual attachment with a known content type (MIME type).

addDataSourceAttachments

public void addDataSourceAttachments(List dataSourceList)
This method accepts a list of byte array data source collection to be sent as attachments.

Parameters:
dataSourceList - a list of collection of byte array data source objects that represents an virtual attachment with a known content type (MIME type).

getDBName

public String getDBName()
This method returns the name of the DB context, either preset by the caller, or "default" if not set.

Returns:
the data context

send

public void send()
          throws Exception
This method does all the dirty work of actually sending the email.

Throws:
Exception - if the internet mailing service fails

send

public void send(String to,
                 String subject,
                 String text)
          throws Exception
This is a convinience method to wrap the send() method.

Parameters:
to - java.lang.String The address to send email to
subject - java.lang.String The subject of the message
text - java.lang.String The text of the message to send
Throws:
Exception - Propagated exception from the send() method

setDBName

public void setDBName(String newDBName)
This method sets the DB context name, used for looking up several Setup parameters

Parameters:
newDBName - String Name of DB context

setFromAddress

public void setFromAddress(String from)
This method sets the address to be used in the From header

Parameters:
from - java.lang.String The from address

setEmailHtmlFormat

public void setEmailHtmlFormat()
Tells the EMail sender to send HTML mail only


setPersonal

public void setPersonal(String personal)
This method sets the address to be used in the From header


getPersonal

public String getPersonal()
This method sets the address to be used in the From header


setSMTPHost

public void setSMTPHost(String host)
This method sets the name of the SMTP server to use

Parameters:
host - java.lang.String Name of SMTP server

setSMTPPassword

public void setSMTPPassword(String password)
This method sets the SMTP password to use for authentication

Parameters:
password - java.lang.String SMTP password to use for authentication

setSMTPUser

public void setSMTPUser(String user)
This method sets the username to use for SMTP authentication

Parameters:
user - java.lang.String Username for SMTP authentication

setSubject

public void setSubject(String subject)
This method sets the value to use for the Subject header

Parameters:
subject - java.lang.String The subject header contents

setText

public void setText(String text)
Thiis method sets the content string of the email message

Parameters:
text - java.lang.String Email message content

setToAddress

public void setToAddress(String to)
This method sets the address to be used in the To header

Parameters:
to - java.lang.String The address to use in To header

setConnectRetryDelay

public void setConnectRetryDelay(long connectRetryDelay)
Sets the connectRetryDelay.

Parameters:
connectRetryDelay - The connectRetryDelay to set

setMaxConnectRetries

public void setMaxConnectRetries(int maxConnectRetries)
Sets the maxConnectRetries.

Parameters:
maxConnectRetries - The maxConnectRetries to set

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.