org.jboss.soa.esb.helpers
Class Email

java.lang.Object
  extended by org.jboss.soa.esb.helpers.Email

public class Email
extends java.lang.Object

Simplifies sending of e-mails with attachments from java.

The message is sent via a subsequent call to the sendMessage() method.

Message Parmeters

The class constructor is supplied the following parameters via a ConfigTree instance:
  1. FROM: valid e-mail address
  2. SENDTO: valid comma separated list of e-mail addresses
  3. SUBJECT: free text that will appear as subject of the e-mail
  4. MESSAGE: free text that will appear as contents of the e-mail
  5. ATTACH: list (as Text children) of valid accessible filenames to attach to the e-mail
All parameters except 'ATTACH' are attributes of the ConfigTree argument. ATTACH parameters (attachments) are added as child ConfigTrees of the supplied ConfigTree.

Author:
Heuristica - Buenos Aires - Argentina

Field Summary
static java.lang.String ATTACH
          ConfigTree attribute : Value of this attribute will be the content of the e-mail's text
static java.lang.String COPYTO
          ConfigTree attribute : comma separated list of Copy recipients
static java.lang.String FROM
          ConfigTree attribute : will be the contents of the From: field in the outgoing message
static java.lang.String MESSAGE
          ConfigTree child Text elements : Each child represents the name of a file to be attached in the outgoing message
static java.lang.String SENDTO
          ConfigTree attribute : comma separated list of recipients
static java.lang.String SUBJECT
          ConfigTree attribute : will be the contents of the Subject: field in the outgoing message
 
Constructor Summary
Email()
          Public constructor.
 
Method Summary
 void addAttachment(java.io.InputStream is, java.lang.String attachmentName)
           
 java.lang.String[] getAttachments()
           
 java.lang.String getCopyTo()
           
 java.lang.String getFrom()
           
 javax.mail.internet.MimeMessage getMailMessage()
          Get the mail message associated with this EsbMail instance.
 java.lang.String getMessage()
           
 java.lang.String getSendTo()
           
 java.lang.String getSubject()
           
 void sendMessage()
          Send the mail message associated with this instance.
 void setAttachments(java.lang.String[] attachments)
           
 void setCopyTo(java.lang.String copyTo)
           
 void setFrom(java.lang.String from)
           
 void setMessage(java.lang.String message)
           
 void setSendTo(java.lang.String sendTo)
           
 void setSubject(java.lang.String subject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FROM

public static final java.lang.String FROM
ConfigTree attribute : will be the contents of the From: field in the outgoing message

See Also:
Constant Field Values

SENDTO

public static final java.lang.String SENDTO
ConfigTree attribute : comma separated list of recipients

See Also:
Constant Field Values

COPYTO

public static final java.lang.String COPYTO
ConfigTree attribute : comma separated list of Copy recipients

See Also:
Constant Field Values

SUBJECT

public static final java.lang.String SUBJECT
ConfigTree attribute : will be the contents of the Subject: field in the outgoing message

See Also:
Constant Field Values

ATTACH

public static final java.lang.String ATTACH
ConfigTree attribute : Value of this attribute will be the content of the e-mail's text

See Also:
Constant Field Values

MESSAGE

public static final java.lang.String MESSAGE
ConfigTree child Text elements : Each child represents the name of a file to be attached in the outgoing message

See Also:
Constant Field Values
Constructor Detail

Email

public Email()
      throws javax.mail.internet.AddressException,
             javax.mail.MessagingException
Public constructor.

Initialises the mail server session and creates the mail message using the information provided in the p_oMessageParms listed above.

The message is sent via a subsequent call to the sendMessage() method.

Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException
See Also:
ConfigTree
Method Detail

sendMessage

public void sendMessage()
                 throws javax.mail.MessagingException
Send the mail message associated with this instance.

Throws:
javax.mail.MessagingException - Unable to transport the message associated with this Email instance.

getMailMessage

public javax.mail.internet.MimeMessage getMailMessage()
                                               throws javax.mail.MessagingException
Get the mail message associated with this EsbMail instance.

Returns:
The mailMessage property value.
Throws:
javax.mail.MessagingException

getAttachments

public java.lang.String[] getAttachments()
Returns:
Returns the attachments.

setAttachments

public void setAttachments(java.lang.String[] attachments)
Parameters:
attachments - The attachments to set.

addAttachment

public void addAttachment(java.io.InputStream is,
                          java.lang.String attachmentName)
                   throws javax.mail.MessagingException,
                          java.io.IOException
Parameters:
is - the InputStream containing the attachment to set
attachmentName - the filename of the attachment in the mail
Throws:
javax.mail.MessagingException
java.io.IOException

getCopyTo

public java.lang.String getCopyTo()
Returns:
Returns the copyTo.

setCopyTo

public void setCopyTo(java.lang.String copyTo)
Parameters:
copyTo - The copyTo to set.

getFrom

public java.lang.String getFrom()
Returns:
Returns the from.

setFrom

public void setFrom(java.lang.String from)
Parameters:
from - The from to set.

getSendTo

public java.lang.String getSendTo()
Returns:
Returns the sendTo.

setSendTo

public void setSendTo(java.lang.String sendTo)
Parameters:
sendTo - The sendTo to set.

getSubject

public java.lang.String getSubject()
Returns:
Returns the subject.

setSubject

public void setSubject(java.lang.String subject)
Parameters:
subject - The subject to set.

getMessage

public java.lang.String getMessage()
Returns:
Returns the message.

setMessage

public void setMessage(java.lang.String message)
Parameters:
message - The message to set.