|
Java Tool Kit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectITT.WAFr.Utilities.Email
The Email class represents an SMTP email message.
This lightweight class provides simple and convenient methods to add or set:
The Email class can send anonymous messages or negotiate authentication for secure SMTP host servers.
This class utilizes and wraps standard JavaMail 1.3.1 and Java Activation Framework 1.0.2 objects and therefore requires the class library for each. WAFr and the Java Tool Kit comes fully packaged with the required .jar files.
| Nested Class Summary | |
class |
Email.AddressException
This exception is thrown when a specified entry could not be converted to a valid email address. |
class |
Email.AttachmentException
This exception is thrown when an attachment fails to be added to the message envelop. |
class |
Email.DeliveryException
This exception is thrown when an email message cannot be delivered due to a server or transport configuration error. |
class |
Email.FileNotFoundException
This exception is thrown when the specified file to be added as a message attachment could not be found. |
class |
Email.NoDataException
This exception is thrown when the specified input stream representing an attachment to be added the email message, contains no data. |
class |
Email.PropertyException
This exception is thrown when an Email object property fails to set due to an invalid value. |
class |
Email.StreamException
This exception is thrown when the specified input stream could not be parsed into a valid message attachment. |
| Constructor Summary | |
Email()
Constructs a new Email object requiring an SMTP host server and credentials to be specified upon sending. |
|
Email(Properties oProperties)
Constructs a new Email object that utilizes the specified Properties object, oProperties, containing a list of settings such as mail.smtp.host. |
|
Email(String sHostServer)
Constructs a new Email object, to be sent anonymously, that utilizes the specified String parameter, sHostServer, as the host server. |
|
Email(String sHostServer,
boolean bAuthenticate)
Constructs a new Email object that utilizes the specified String parameter, sHostServer, as the host server and whether or not authentication should be attempted when sending the message, determined by the boolean, bAuthenticate |
|
| Method Summary | |
void |
AddAttachment(byte[] iContent,
String sFileName,
String sContentType)
A convenience method or alias to Attachment(byte[],String,String). |
void |
AddAttachment(byte[] iContent,
String sFileName,
String sContentType,
String sContentId)
A convenience method or alias to Attachment(byte[],String,String,String). |
void |
AddAttachment(File oFile)
A convenience method or alias to Attachment(File). |
void |
AddAttachment(File oFile,
String sContentId)
A convenience method or alias to Attachment(File,String). |
void |
AddAttachment(String sFilePath)
A convenience method or alias to Attachment(String). |
void |
AddAttachment(String sFilePath,
String sContentId)
A convenience method or alias to Attachment(String,String). |
void |
AddAttachment(Upload.PostedFile oContent)
A convenience method or alias to Attachment(Upload.PostedFile). |
void |
AddAttachment(Upload.PostedFile oContent,
String sContentId)
A convenience method or alias to Attachment(Upload.PostedFile,String). |
void |
AddBcc(String sAddress)
Preserves the "BCC" (blind carbon copy) property of the message and appends the specified String representing a valid email address. |
void |
AddBcc(String[] sAddresses)
Preserves the "BCC" (blind carbon copy) property of the message and appends the specified String array representing a list of a valid email addresses. |
void |
AddCc(String sAddress)
Preserves the "CC" (carbon copy) property of the message and appends the specified String representing a valid email address. |
void |
AddCc(String[] sAddresses)
Preserves the "CC" (carbon copy) property of the message and appends the specified String array representing a list of a valid email addresses. |
void |
AddFrom(String sAddress)
Preserves the "FROM" property of the message and appends the specified String representing a valid email address. |
void |
AddFrom(String[] sAddresses)
Preserves the "FROM" property of the message and appends the specified String array representing a list of a valid email addresses. |
void |
AddHeader(String sName,
String sValue)
Preserves the current values of the specified header field of the message and appends the specified String value. |
void |
AddTo(String sAddress)
Preserves the "TO" property of the message and appends the specified String representing a valid email address. |
void |
AddTo(String[] sAddresses)
Preserves the "TO" property of the message and appends the specified String array representing a list of a valid email addresses. |
void |
Attachment(byte[] iContent,
String sFileName,
String sContentType)
Preserves any existing message attachments and adds the byte array specified in the input parameter, iContent, containing the content of a file, to the attachment envelop. |
void |
Attachment(byte[] iContent,
String sFileName,
String sContentType,
String sContentId)
Preserves any existing message attachments and adds the byte array specified in the input parameter, iContent, containing the content of a file, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId. |
void |
Attachment(File oFile)
Preserves any existing message attachments and adds the File object, oFile, to the attachment envelop. |
void |
Attachment(File oFile,
String sContentId)
Preserves any existing message attachments and adds the File object, oFile, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId. |
void |
Attachment(String sFilePath)
Preserves any existing message attachments and adds the file with the path of sFilePath to the attachment envelop. |
void |
Attachment(String sFilePath,
String sContentId)
Preserves any existing message attachments and adds the file with the path specified in the String parameter, sFilePath, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId. |
void |
Attachment(Upload.PostedFile oContent)
Preserves any existing message attachments and adds the data represented by the Upload.PostedFile, oContent, to the attachment envelop. |
void |
Attachment(Upload.PostedFile oContent,
String sContentId)
Preserves any existing message attachments and adds the data represented by the Upload.PostedFile, oContent, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId. |
void |
Bcc(String sAddress)
Clears the "BCC" (blind carbon copy) property of the message and sets it to the specified String representing a valid email address. |
void |
Bcc(String[] sAddresses)
Clears the "BCC" (blind carbon copy) property of the message and sets it to the specified String array representing a list of a valid email addresses. |
void |
Body(String sBody)
Set the "BODY" property of the message and to the specified String. |
void |
Cc(String sAddress)
Clears the "CC" (carbon copy) property of the message and sets it to the specified String representing a valid email address. |
void |
Cc(String[] sAddresses)
Clears the "CC" (carbon copy) property of the message and sets it to the specified String array representing a list of a valid email addresses. |
void |
DeleteHeader(String sName)
Deletes the specified header from the message. |
void |
DeleteHeaders(String[] sNames)
Deletes the specified headers from the message. |
void |
From(String sAddress)
Clears the "FROM" property of the message and sets it to the specified String representing a valid email address. |
void |
Header(String sName,
String sValue)
Clears the current value of the specified header field of the message and sets it to the specified String value. |
void |
ReplyTo(String sAddress)
Clears the "REPLY TO" property of the message and sets it to the specified String representing a valid email address. |
void |
ReplyTo(String[] sAddresses)
Clears the "REPLY TO" property of the message and sets it to the specified String array representing a list of a valid email addresses. |
void |
Send()
Sends the message contained within the Email object. |
void |
Send(String sUsername,
String sPassword)
Sends the message contained withing the Email object. |
void |
Send(String sHost,
String sUsername,
String sPassword)
Sends the message contained withing the Email object. |
void |
Sender(String sAddress)
Clears the "SENDER" header field of the message and sets it to the specified String representing a valid email address. |
void |
SentDate(Date dDate)
Clears the "DATE" header field of the message and sets it to the specified Date representing the date and time the message was sent. |
void |
Subject(String sSubject)
Sets the "SUBJECT" property of the message to the specified text String. |
void |
To(String sAddress)
Clears the "TO" property of the message and sets it to the specified String representing a valid email address. |
void |
To(String[] sAddresses)
Clears the "TO" property of the message and sets it to the specified String array representing a list of a valid email addresses. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Email()
Email object requiring an SMTP host server and credentials to be specified upon sending.
Send(String,String,String)public Email(Properties oProperties)
Email object that utilizes the specified Properties object, oProperties, containing a list of settings such as mail.smtp.host.
oProperties - a Properties object containing SMTP protocol provider settings specified in com.sun.mail.smtp package description of the JavaMail API.Send()public Email(String sHostServer)
Email object, to be sent anonymously, that utilizes the specified String parameter, sHostServer, as the host server.
sHostServer - the name or IP address of the SMTP host server to use when sending message anonymously.Send()
public Email(String sHostServer,
boolean bAuthenticate)
Email object that utilizes the specified String parameter, sHostServer, as the host server and whether or not authentication should be attempted when sending the message, determined by the boolean, bAuthenticate, parameter.
- Parameters:
sHostServer - the name or IP address of the SMTP host server to use when sending message.bAuthenticate - true to attempt authentication, false to send anonymously.- See Also:
Send(),
Send(String,String)| Method Detail |
public void AddAttachment(byte[] iContent,
String sFileName,
String sContentType)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(byte[],String,String).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(byte[],String,String)
public void AddAttachment(byte[] iContent,
String sFileName,
String sContentType,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(byte[],String,String,String).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(byte[],String,String,String)
public void AddAttachment(File oFile)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(File).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(File)
public void AddAttachment(File oFile,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(File,String).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(File,String)
public void AddAttachment(String sFilePath)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(String).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(String)
public void AddAttachment(String sFilePath,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(String,String).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(String,String)
public void AddAttachment(Upload.PostedFile oContent)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(Upload.PostedFile).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(Upload.PostedFile)
public void AddAttachment(Upload.PostedFile oContent,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
Attachment(Upload.PostedFile,String).
Email.AttachmentException
Email.FileNotFoundException
Email.NoDataException
Email.StreamExceptionAttachment(Upload.PostedFile,String)
public void AddBcc(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.Bcc(String)
public void AddBcc(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.Bcc(String[])
public void AddCc(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.Cc(String)
public void AddCc(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.Cc(String[])
public void AddFrom(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.From(String)
public void AddFrom(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.
public void AddHeader(String sName,
String sValue)
throws Email.PropertyException
sName - a String containing the name of the message header field.sValue - a String containing the value to append to the message header.
Email.PropertyException - if the property fails to properly set.
public void AddTo(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.To(String)
public void AddTo(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.To(String[])
public void Attachment(byte[] iContent,
String sFileName,
String sContentType)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
iContent, containing the content of a file, to the attachment envelop.
The file name to be associated with the attachment can be any String indicated within the parameter, sFileName. A String containing the associated MIME content type is required as the parameter, sContentType. If a null or empty-String value is passed for sContentType, a content type of application/octet-stream will be substituted.
This method will not provide the means to reference the attachment within the HTML message body.
iContent - a byte array containing the content of the file to be attached to the message.sFileName - a String containing the file name for the attachment.sContentType - a String containing the MIME content type for the attachment.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(byte[],String,String,String)
public void Attachment(byte[] iContent,
String sFileName,
String sContentType,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
iContent, containing the content of a file, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId.
The file name to be associated with the attachment can be any String indicated within the parameter, sFileName. A String containing the associated MIME content type is required for the parameter, sContentType. If a null or empty-String value is passed for sContentType, a content type of application/octet-stream will be substituted.
This method is used to add a relative attachment for referencing within the HTML message body.
iContent - a byte array containing the content of the file to be attached to the message.sFileName - a String containing the file name for the attachment.sContentType - a String containing the MIME content type for the attachment.sContentId - a String containing the reference ID for the attachment.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(byte[],String,String)
public void Attachment(File oFile)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
oFile, to the attachment envelop.
This method will not provide the means to reference the attachment within the HTML message body.
oFile - a File object to be attached to the message.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(File,String)
public void Attachment(File oFile,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
oFile, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId.
This method is used to add a relative attachment for referencing within the HTML message body.
oFile - a File object to be attached to the message.sContentId - a String containing the reference ID for the attachment.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(File)
public void Attachment(String sFilePath)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
sFilePath to the attachment envelop.
This method will not provide the means to reference the attachment within the HTML message body.
sFilePath - a String containing the file path of the file to be attached to the message.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(String,String)
public void Attachment(String sFilePath,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
sFilePath, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId.
This method is used to add a relative attachment for referencing within the HTML message body.
sFilePath - a String containing the file path of the file to be attached to the message.sContentId - a String containing the reference ID for the attachment.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(String)
public void Attachment(Upload.PostedFile oContent)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
oContent, to the attachment envelop.
This method will not provide the means to reference the attachment within the HTML message body.
oContent - an Upload.PostedFile object containing the file data to be attached to the message.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(Upload.PostedFile,String)
public void Attachment(Upload.PostedFile oContent,
String sContentId)
throws Email.AttachmentException,
Email.FileNotFoundException,
Email.NoDataException,
Email.StreamException
oContent, to the attachment envelop with a relative reference ID specified within the String parameter, sContentId.
This method is used to add a relative attachment for referencing within the HTML message body.
oContent - an Upload.PostedFile object containing the file data to be attached to the message.sContentId - a String containing the reference ID for the attachment.
Email.AttachmentException - if the attachments fails to bind to the message.
Email.FileNotFoundException - if the file to be attached cannot be located.
Email.NoDataException - if the attachment contains no data.
Email.StreamException - if the attachment data stream cannot be successfully parsed.Attachment(Upload.PostedFile)
public void Bcc(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.AddBcc(String)
public void Bcc(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.AddBcc(String[])
public void Body(String sBody)
throws Email.PropertyException
The String may contain HTML or plain text. If the text contains HTML, the message will contain both an HTML and plain text version of the message body to accommodate all email client applications.
sBody - a String containing the body content of the message.
Email.PropertyException - if the property fails to properly set.
public void Cc(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.AddCc(String)
public void Cc(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.AddCc(String[])
public void DeleteHeader(String sName)
throws Email.PropertyException
sName - a String containing the name of the message header field.
Email.PropertyException - if the property fails to properly delete.
public void DeleteHeaders(String[] sNames)
throws Email.PropertyException
sNames - a String array containing the names of the message header fields.
Email.PropertyException - if any property fails to properly delete.
public void From(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.AddFrom(String)
public void Header(String sName,
String sValue)
throws Email.PropertyException
sName - a String containing the name of the message header field.sValue - a String containing the value to set the message header.
Email.PropertyException - if the property fails to properly set.
public void ReplyTo(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.ReplyTo(String)
public void ReplyTo(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.ReplyTo(String[])
public void Send()
throws Email.DeliveryException
Email object.
This method is used for Email objects constructed with explicitly declared SMTP host servers using Email(String), Email(String,boolean) or Email(Properties).
Email.DeliveryException - if the message fails to deliver successfully.Send(String,String),
Send(String,String,String)
public void Send(String sUsername,
String sPassword)
throws Email.DeliveryException
Email object.
This method is used for Email objects constructed with explicitly declared SMTP host servers requiring authentication using Email(String,boolean) passing true, or Email(Properties) with the mail.smtp.auth property set to true.
Email.DeliveryException - if the message fails to deliver successfully.Send(String,String),
Send(String,String,String)
public void Send(String sHost,
String sUsername,
String sPassword)
throws Email.DeliveryException
Email object.
This method is used for Email objects constructed without explicitly declared SMTP host servers using Email().
Email.DeliveryException - if the message fails to deliver successfully.Send(String,String),
Send(String,String,String)
public void Sender(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.
public void SentDate(Date dDate)
throws Email.PropertyException
dDate - a Date containing the date and time the message was sent.
Email.PropertyException - if the property fails to properly set.
public void Subject(String sSubject)
throws Email.PropertyException
sSubject - a String containing the subject content of the message.
Email.PropertyException - if the property fails to properly set.
public void To(String sAddress)
throws Email.PropertyException,
Email.AddressException
sAddress - a single String representing a valid email address.
Email.AddressException - if the String email address cannot be successfully parsed.
Email.PropertyException - if the property fails to properly set.AddTo(String)
public void To(String[] sAddresses)
throws Email.PropertyException,
Email.AddressException
sAddresses - an array of Strings representing valid email addresses.
Email.AddressException - if any of the String email addresses cannot be successfully parsed.
Email.PropertyException - if any property fails to properly set.AddTo(String[])
|
Java Tool Kit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||