jodd.mail
Class Email

java.lang.Object
  extended by jodd.mail.Email

public class Email
extends java.lang.Object

E-mail bean contains all parts of an email and handle attachments. todo Default values ? todo Add more attachments handlers


Constructor Summary
Email()
           
 
Method Summary
 void addAttachment(java.lang.String fileName)
          Adds an existing file as attachment.
 void addAttachment(java.lang.String fileName, javax.activation.DataHandler dh)
          Adds a generic attachment.
 void addAttachment(java.lang.String fileName, java.lang.String data)
          Adds a HTML attachment.
 void addHeader(java.lang.String name, java.lang.String value)
          Add single header.
 void addHeaders(java.util.Map map)
          Add map of headers.
 javax.mail.internet.MimeBodyPart getAttachmentBodyPart(int i)
          Returns one attachment body part, for javamail usage.
 java.lang.String[] getBcc()
          Returns array of BCC addresses.
 java.lang.String[] getCc()
          Returns array of CC addresses.
 java.lang.String getFrom()
          Returns FROM address.
 java.lang.String getMessage()
          Returns message text, either plain or HTML.
 java.util.Date getSentDate()
          Returns e-mails sent date.
 java.lang.String getSubject()
          Returns message subject.
 java.lang.String[] getTo()
          Returns the array of TO addresses.
 int getTotalAttachments()
          Returns total number of attachments.
 boolean isHtmlMessage()
          Returns true if message is HTML, otherwise false.
 void setBcc(java.lang.String bcc)
          Sets single BCC address.
 void setBcc(java.lang.String[] bcc)
          Sets multiple BCC addresses.
 void setCc(java.lang.String cc)
          Sets single CC address
 void setCc(java.lang.String[] cc)
          Sets multiple CC addresses.
 void setFrom(java.lang.String from)
          Sets the FROM address
 void setHtmlMessage(java.lang.String htmlMessage)
          Sets HTML message text.
 void setMessage(java.lang.String message)
          Sets plain message text.
 void setSentDate()
          Sets current date as e-mails sent date.
 void setSentDate(java.util.Date date)
          Sets e-mails sent date.
 void setSubject(java.lang.String subject)
          Sets message subject.
 void setTo(java.lang.String to)
          Sets single TO address.
 void setTo(java.lang.String[] to)
          Sets multiple TO addresses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Email

public Email()
Method Detail

setFrom

public void setFrom(java.lang.String from)
Sets the FROM address

Parameters:
from - FROM address

getFrom

public java.lang.String getFrom()
Returns FROM address.

Returns:
FROM address

setTo

public void setTo(java.lang.String to)
Sets single TO address.

Parameters:
to - single TO address

setTo

public void setTo(java.lang.String[] to)
Sets multiple TO addresses.

Parameters:
to - array of TO addresses

getTo

public java.lang.String[] getTo()
Returns the array of TO addresses.

Returns:
array of TO addresses

setCc

public void setCc(java.lang.String cc)
Sets single CC address

Parameters:
cc - single CC address

setCc

public void setCc(java.lang.String[] cc)
Sets multiple CC addresses.

Parameters:
cc - array of CC address.

getCc

public java.lang.String[] getCc()
Returns array of CC addresses.

Returns:
array of CC addresses

setBcc

public void setBcc(java.lang.String bcc)
Sets single BCC address.

Parameters:
bcc - single BCC address

setBcc

public void setBcc(java.lang.String[] bcc)
Sets multiple BCC addresses.

Parameters:
bcc - array of BCC address.

getBcc

public java.lang.String[] getBcc()
Returns array of BCC addresses.

Returns:
array of BCC addresses

setSubject

public void setSubject(java.lang.String subject)
Sets message subject.

Parameters:
subject - subject of a message

getSubject

public java.lang.String getSubject()
Returns message subject.

Returns:
message subject

setMessage

public void setMessage(java.lang.String message)
Sets plain message text.

Parameters:
message - plain message text

getMessage

public java.lang.String getMessage()
Returns message text, either plain or HTML.

Returns:
message text

setHtmlMessage

public void setHtmlMessage(java.lang.String htmlMessage)
Sets HTML message text.

Parameters:
htmlMessage - HTML message text

isHtmlMessage

public boolean isHtmlMessage()
Returns true if message is HTML, otherwise false.

Returns:
true if message is HTML, otherwise false

getTotalAttachments

public int getTotalAttachments()
Returns total number of attachments.

Returns:
total number of attachments

getAttachmentBodyPart

public javax.mail.internet.MimeBodyPart getAttachmentBodyPart(int i)
Returns one attachment body part, for javamail usage.

Parameters:
i - index of attachment
Returns:
attachment body part

addAttachment

public void addAttachment(java.lang.String fileName,
                          javax.activation.DataHandler dh)
                   throws javax.mail.MessagingException
Adds a generic attachment.

Parameters:
fileName - file name of attachment
dh - DataHandler
Throws:
javax.mail.MessagingException

addAttachment

public void addAttachment(java.lang.String fileName,
                          java.lang.String data)
                   throws javax.mail.MessagingException
Adds a HTML attachment.

Parameters:
fileName - attachment file name
data - HTML data
Throws:
javax.mail.MessagingException

addAttachment

public void addAttachment(java.lang.String fileName)
                   throws javax.mail.MessagingException
Adds an existing file as attachment.

Parameters:
fileName - local name of a file to attach
Throws:
javax.mail.MessagingException

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Add single header.

Parameters:
name - header name
value - header value

addHeaders

public void addHeaders(java.util.Map map)
Add map of headers.

Parameters:
map - headers map

setSentDate

public void setSentDate(java.util.Date date)
Sets e-mails sent date. If input parameter is null then date will be when email is physically sent.

Parameters:
date - sent date value

setSentDate

public void setSentDate()
Sets current date as e-mails sent date.


getSentDate

public java.util.Date getSentDate()
Returns e-mails sent date. If return value is null then date will be set during the process of sending.

Returns:
email's sent date or null if it will be set later.


Copyright ©2008 Jodd Team