com.pushtotest.tool.protocolhandler
Class MailBody

java.lang.Object
  extended by com.pushtotest.tool.protocolhandler.MailBody
All Implemented Interfaces:
Body

public class MailBody
extends java.lang.Object
implements Body

This is an implementation of the Body interface for the Mail protocol. The Body handles message encoding, including MIME and attachments.


Constructor Summary
MailBody(javax.mail.Session theSession)
          Constructor must pass in a Session object that is used to work with MIME email messages and attachments
 
Method Summary
 void addAddress(java.lang.String theAdr)
          Adds an address to the message
 void addHeaders(java.net.HttpURLConnection con)
          Not needed in this context
 void addParameter(java.lang.String name, java.lang.String value)
          Pretty much useless in an email context
 java.lang.String getBody()
          Not needed in this context
 java.lang.String getFrom()
          Gets the "from" address
 javax.mail.internet.MimeMessage getMessage()
          Construct the MIME message
 javax.mail.internet.MimeBodyPart getNewBodyPart()
          Creates a new MIME message part for sending attachments
 java.lang.String getSubject()
          Gets the message subject line
 java.lang.String getText()
          Gets the message text
 java.lang.String id()
          Returns an id for this protocol.
 void setFrom(java.lang.String thefrom)
          Sets the "from" address
 void setSubject(java.lang.String thesub)
          Sets the message subject line
 void setText(java.lang.String thetext)
          Sets the message text
 java.lang.String toString()
          Returns the content of the body to be used by the Protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MailBody

public MailBody(javax.mail.Session theSession)
Constructor must pass in a Session object that is used to work with MIME email messages and attachments

Parameters:
Session - value generated by the MailProtocol object constructor, see MailProtocol.getSession()
Method Detail

getMessage

public javax.mail.internet.MimeMessage getMessage()
                                           throws ToolException
Construct the MIME message

Returns:
Complete message ready to send to the smtp host
Throws:
ToolException

getNewBodyPart

public javax.mail.internet.MimeBodyPart getNewBodyPart()
Creates a new MIME message part for sending attachments


addAddress

public void addAddress(java.lang.String theAdr)
Adds an address to the message

Parameters:
Any - SMTP email address

setSubject

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


getSubject

public java.lang.String getSubject()
Gets the message subject line


setText

public void setText(java.lang.String thetext)
Sets the message text


getText

public java.lang.String getText()
Gets the message text


setFrom

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


getFrom

public java.lang.String getFrom()
Gets the "from" address


id

public java.lang.String id()
Returns an id for this protocol. The id is a string that will be used to uniquily identify the protocol.

Specified by:
id in interface Body
Returns:
The id for this Protocol.

toString

public java.lang.String toString()
Returns the content of the body to be used by the Protocol.

Overrides:
toString in class java.lang.Object
Returns:
All of the content that should be sent as the Protocol body.

addParameter

public void addParameter(java.lang.String name,
                         java.lang.String value)
Pretty much useless in an email context

Specified by:
addParameter in interface Body
Parameters:
name - The name of the header variable.
value - The value to set for this header variable.

getBody

public java.lang.String getBody()
                         throws ToolException
Not needed in this context

Specified by:
getBody in interface Body
Returns:
All of the content that should be sent as the Protocol body.
Throws:
ToolException

addHeaders

public void addHeaders(java.net.HttpURLConnection con)
Not needed in this context

Specified by:
addHeaders in interface Body
Parameters:
con - The HttpURLConnection object that will communicate with the host using HTTP protocols