ejel
Class Email

java.lang.Object
  extended by ejel.Email
All Implemented Interfaces:
java.lang.Cloneable

public class Email
extends java.lang.Object
implements java.lang.Cloneable

Hold all the data needed to send an email via a SMTP Server to one or more recipients


Field Summary
static java.lang.String EMAIL_REGEX
          Regular expression used to validate email addresses
static java.lang.String IMG_SRC_REGEX
          Regular expression used to extract html IMG tag source file
 
Constructor Summary
Email(java.lang.String sndr, java.lang.String rply2, boolean dlvryRcpt, java.lang.String sbjct, java.io.File txtFile, java.io.File htmlFile)
          Constructs an email object that holds all the needed data to send emails
Email(java.lang.String sndr, java.lang.String rply2, boolean dlvryRcpt, java.lang.String sbjct, java.lang.String txt, java.lang.String html)
          Construct an Email object that holds all the needed data to send emails
 
Method Summary
 java.lang.Object clone()
          Clones the Email object and returns a cloned Email object
 Attachment[] convertFilesToContentIDs(java.lang.String workDir)
          Converts the images files attached to the html message to content IDs and returns the Attachment array of the attached files detected.
 java.lang.String getCharset()
          Gets the default charset name of the message html/text
 java.lang.String getContentTransferEncoding()
          Gets the content transfer encoding name of the message html/text
 boolean getDeliveryReceiptStatus()
          Gets the delivery receipt status
 java.lang.String getHtmlMessage()
          Gets the html message content
 java.lang.String getReplyToAddress()
          Gets the reply to email address
 java.lang.String getSenderName()
          Gets the sender friendly name
 java.lang.String getSubject()
          Gets the email subject
 java.lang.String getTextMessage()
          Gets the text message content of the email
 void setCharset(java.lang.String newCharset)
          Sets a new charset name for the email message content
 void setContentTransferEncoding(java.lang.String cte)
          Sets the Content Transfer Encoding for the email message content.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMAIL_REGEX

public static final java.lang.String EMAIL_REGEX
Regular expression used to validate email addresses

See Also:
Constant Field Values

IMG_SRC_REGEX

public static final java.lang.String IMG_SRC_REGEX
Regular expression used to extract html IMG tag source file

See Also:
Constant Field Values
Constructor Detail

Email

public Email(java.lang.String sndr,
             java.lang.String rply2,
             boolean dlvryRcpt,
             java.lang.String sbjct,
             java.lang.String txt,
             java.lang.String html)
      throws java.lang.IllegalArgumentException
Construct an Email object that holds all the needed data to send emails

Parameters:
sndr - Sender friendly name
rply2 - Reply to email address or null
dlvryRcpt - Set to true to request a delivery receipt from the recipients
sbjct - Email subject
txt - Text message content
html - Html messsage content
Throws:
java.lang.IllegalArgumentException

Email

public Email(java.lang.String sndr,
             java.lang.String rply2,
             boolean dlvryRcpt,
             java.lang.String sbjct,
             java.io.File txtFile,
             java.io.File htmlFile)
      throws java.lang.IllegalArgumentException,
             java.io.FileNotFoundException,
             java.io.IOException
Constructs an email object that holds all the needed data to send emails

Parameters:
sndr - Sender friendly name
rply2 - Reply to email address or null
dlvryRcpt - Set to true to request a delivery receipt from the recipients
sbjct - Email subject
txtFile - File object instance to load the plain text message from or null to ignore
htmlFile - File object instance to load the html message from or null to ignore
Throws:
java.lang.IllegalArgumentException
java.io.FileNotFoundException
java.io.IOException
Method Detail

getCharset

public java.lang.String getCharset()
Gets the default charset name of the message html/text

Returns:
the default charset name of the message html/text

getContentTransferEncoding

public java.lang.String getContentTransferEncoding()
Gets the content transfer encoding name of the message html/text

Returns:
the content transfer encoding name of the message html/text

convertFilesToContentIDs

public Attachment[] convertFilesToContentIDs(java.lang.String workDir)
                                      throws java.io.FileNotFoundException
Converts the images files attached to the html message to content IDs and returns the Attachment array of the attached files detected. External code must add Attachment objects so the email client may show the html message correctly. This function alter the html message content.

Parameters:
workDir - The parent folder of relative files path
Returns:
the Attachment array of the attached files detected.
Throws:
java.io.FileNotFoundException

getSenderName

public java.lang.String getSenderName()
Gets the sender friendly name

Returns:
the sender friendly name

getReplyToAddress

public java.lang.String getReplyToAddress()
Gets the reply to email address

Returns:
the reply to email address

getSubject

public java.lang.String getSubject()
Gets the email subject

Returns:
the email subject

getTextMessage

public java.lang.String getTextMessage()
Gets the text message content of the email

Returns:
the text message content of the email

getHtmlMessage

public java.lang.String getHtmlMessage()
Gets the html message content

Returns:
the html message content

getDeliveryReceiptStatus

public boolean getDeliveryReceiptStatus()
Gets the delivery receipt status

Returns:
The delivery receipt status

clone

public java.lang.Object clone()
Clones the Email object and returns a cloned Email object

Overrides:
clone in class java.lang.Object
Returns:
A cloned Email object

setCharset

public void setCharset(java.lang.String newCharset)
                throws java.lang.IllegalArgumentException
Sets a new charset name for the email message content

Parameters:
newCharset - The charset name for the email message content
Throws:
java.lang.IllegalArgumentException

setContentTransferEncoding

public void setContentTransferEncoding(java.lang.String cte)
                                throws java.lang.IllegalArgumentException
Sets the Content Transfer Encoding for the email message content. Supported charset names are : 7bit, 8bit, quoted-printable, base64, binary, uuencode

Parameters:
cte - The Content Transfer Encoding for the email message content
Throws:
java.lang.IllegalArgumentException