com.lavantech.net.mail
Class Message

java.lang.Object
  extended bycom.lavantech.net.mail.Message

public class Message
extends java.lang.Object

This class represents a Email Message that can be emailed. The Message has information on From Email Address, To Email Addresses, CC Email Addresses, BCC Email Addresses, Subject, Message and Attachments.


Field Summary
 EmailAddress[] bcc
           
 EmailAddress[] cc
           
 java.lang.String charset
           
 java.util.Calendar dateTime
           
 EmailAddress from
           
 java.lang.String message
           
 EmailAddress replyTo
           
 EmailAddress returnPath
           
 java.lang.String subject
           
 EmailAddress[] to
           
 
Constructor Summary
Message(EmailAddress from, EmailAddress[] to, EmailAddress[] cc, EmailAddress[] bcc, java.lang.String subject, java.lang.String message)
          Constructs a message with the given From address, To addresss, CC addresses, BCC addresses, Subject and Message.
Message(EmailAddress returnPath, EmailAddress from, EmailAddress replyTo, EmailAddress[] to, EmailAddress[] cc, EmailAddress[] bcc, java.lang.String subject, java.lang.String message, java.lang.String charset, java.io.File[] attachments)
          Constructs a message with more details than the simple constructor.
 
Method Summary
 void addAttachment(java.io.File file)
          Add an attachment to the message.
 java.io.File[] getAttachments()
          Returns an array of attachments in the message.
 java.util.Calendar getDateTime()
          Returns the message Date and Time.
 void removeAttachment(java.io.File file)
          Remove an attachment to the message.
 void setDateTime(java.util.Calendar cal)
          Sets the message Date and Time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

from

public EmailAddress from

replyTo

public EmailAddress replyTo

returnPath

public EmailAddress returnPath

to

public EmailAddress[] to

cc

public EmailAddress[] cc

bcc

public EmailAddress[] bcc

subject

public java.lang.String subject

message

public java.lang.String message

charset

public java.lang.String charset

dateTime

public java.util.Calendar dateTime
Constructor Detail

Message

public Message(EmailAddress from,
               EmailAddress[] to,
               EmailAddress[] cc,
               EmailAddress[] bcc,
               java.lang.String subject,
               java.lang.String message)
Constructs a message with the given From address, To addresss, CC addresses, BCC addresses, Subject and Message.

Parameters:
from - From Email Address. FromAddress is mandatory for this message to be mailable.
to - An array of To Email Addresses. This can be null, if there is no "To" Address.
cc - An array of CC Email Addresses. This can be null, if there is no "CC" Address.
bcc - An array of BCC Email Addresses. This can be null, if there is no "BCC" Address.
subject - Subject of the message. This can be null.
message - Message to be sent. This can't be null.

Message

public Message(EmailAddress returnPath,
               EmailAddress from,
               EmailAddress replyTo,
               EmailAddress[] to,
               EmailAddress[] cc,
               EmailAddress[] bcc,
               java.lang.String subject,
               java.lang.String message,
               java.lang.String charset,
               java.io.File[] attachments)
        throws java.io.UnsupportedEncodingException
Constructs a message with more details than the simple constructor.

Parameters:
returnPath - Email Address where errors are sent in case of failed delivery. This is useful for mailing list where bounced mails shouldn't go back to the mailing list.
from - From Email Address. FromAddress is mandatory for this message to be mailable.
replyTo - Email Address where reply for this mail will be sent. This could be different from the From Address.
to - An array of To Email Addresses. This can be null, if there is no "To" Address.
cc - An array of CC Email Addresses. This can be null, if there is no "CC" Address.
bcc - An array of BCC Email Addresses. This can be null, if there is no "BCC" Address.
subject - Subject of the message. This can be null.
message - Message to be sent. This can't be null.
charset - Canonical name of the character set of the message.
attachments - Array of files that needs to be attached to the message. null can be passed if no attachments.
Method Detail

addAttachment

public void addAttachment(java.io.File file)
                   throws AttachmentException
Add an attachment to the message.

Parameters:
file - Attachment file that needs to be added to the message.
Throws:
AttachmentException - If the Attachment File doesn't exists or can't be read.

removeAttachment

public void removeAttachment(java.io.File file)
Remove an attachment to the message.

Parameters:
file - Attachment file that needs to be removed from the message.

getAttachments

public java.io.File[] getAttachments()
Returns an array of attachments in the message.


setDateTime

public void setDateTime(java.util.Calendar cal)
Sets the message Date and Time.


getDateTime

public java.util.Calendar getDateTime()
Returns the message Date and Time.