com.goldeninnovations.smp
Class EmailMessage

java.lang.Object
  extended by com.goldeninnovations.smp.EmailMessage

public abstract class EmailMessage
extends Object

Represents an incoming Email Message. This class contains the raw message and convenience accessor methods to enable access to individual message attributes.

This class is not thread-safe.


Constructor Summary
EmailMessage()
           
 
Method Summary
abstract  void addToAddress(EmailAddress address)
          Email addresses of the recipients specified by the remote SMPT server.
 String getContentType()
          Returns the Content-Type for this email, if specified.
abstract  EmailAddress getFromAddress()
          The email address of the sender specified by the remote SMTP server.
 String getFromHeader()
          The value of the From header
 String getHeader(String headerName)
          Returns the value of first header found that matches the header name.
 List<String> getHeaders()
          Returns a collection of the headers from this message.
 String[] getHeaders(String headerName)
          Returns all of the values of the specified header name.
 MessagePart getMessagePart(int index)
          Returns the specified MessagePart
 int getMessagePartCount()
          The number of MessageParts in this message.
 List<MessagePart> getMessageParts()
          A List of the MessageParts found in this message.
abstract  String getRawMessage()
          The entire message as a single String.
abstract  InetAddress getSenderInetAddress()
          The Internet Address of the sending SMTP Server
 String getSubjectHeader()
          The value of the Subject header.
abstract  List<EmailAddress> getToAddress()
          Email addresses of the recipients specified by the remote SMPT server.
 String getToHeader()
          The value of the (first) To header
 String[] getToHeaders()
          The values of all the To headers
 boolean isMulitpartMessage()
          Returns true if this message is a Multi-Part Message.
abstract  void setFrom(EmailAddress address)
          The email address of the sender specified by the remote SMTP server.
abstract  void setRawMessage(String rawMessage)
          The entire message as a single String
abstract  void setSenderInetAddress(InetAddress senderAddress)
          The Internet Address of the sending SMTP Server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmailMessage

public EmailMessage()
Method Detail

getSenderInetAddress

public abstract InetAddress getSenderInetAddress()
The Internet Address of the sending SMTP Server

Returns:
address of the sending SMTP server.

setSenderInetAddress

public abstract void setSenderInetAddress(InetAddress senderAddress)
The Internet Address of the sending SMTP Server

Parameters:
senderAddress - address of the sending SMTP server.

getFromAddress

public abstract EmailAddress getFromAddress()
The email address of the sender specified by the remote SMTP server.

This may be different than the email address in the from header.

Returns:
email address of the sender.

setFrom

public abstract void setFrom(EmailAddress address)
The email address of the sender specified by the remote SMTP server.

This may be different than the email address in the from header.

Parameters:
address - email address of the sender.

getToAddress

public abstract List<EmailAddress> getToAddress()
Email addresses of the recipients specified by the remote SMPT server.

This may be different than the email address in the from header.

Returns:
email addresses of the recipients.

addToAddress

public abstract void addToAddress(EmailAddress address)
Email addresses of the recipients specified by the remote SMPT server.

This may be different than the email address in the from header.

Parameters:
address - addresses of the recipients.

getRawMessage

public abstract String getRawMessage()
The entire message as a single String.

Returns:
the entire message

setRawMessage

public abstract void setRawMessage(String rawMessage)
The entire message as a single String

Parameters:
rawMessage - the entire message

getSubjectHeader

public String getSubjectHeader()
The value of the Subject header.

Returns:
value of the Subject header.

getFromHeader

public String getFromHeader()
The value of the From header

This can be different from the fromAddress. This value is specified in the message header while the fromAddress is given to the SMTP server.

Returns:
value of the From header

getToHeader

public String getToHeader()
The value of the (first) To header

This can be different from the toAddress. This value is specified in the message header while the toAddress is given to the SMTP server.

Returns:
value of the (first) To header.

getToHeaders

public String[] getToHeaders()
The values of all the To headers

This can be different from the toAddress. This value is specified in the message header while the toAddress is given to the SMTP server.

Returns:
values of all the To headers.

getContentType

public String getContentType()
Returns the Content-Type for this email, if specified.

Returns:
the value of the Content-Type header

isMulitpartMessage

public boolean isMulitpartMessage()
Returns true if this message is a Multi-Part Message.

Returns:
true if Multi-Part

getMessagePartCount

public int getMessagePartCount()
The number of MessageParts in this message.

Returns:
the number of MessageParts

getMessagePart

public MessagePart getMessagePart(int index)
Returns the specified MessagePart

Parameters:
index - the index of the MessagePart to return.
Returns:
the MessagePart

getMessageParts

public List<MessagePart> getMessageParts()
A List of the MessageParts found in this message.

Returns:
List of MessagePart, or empty list.

getHeaders

public List<String> getHeaders()
Returns a collection of the headers from this message.

The headers are all a single line in the form of '<key>: <value>'

Returns:
List of header Strings

getHeader

public String getHeader(String headerName)
Returns the value of first header found that matches the header name.

Parameters:
headerName - the name of the header to find.
Returns:
the value of the header.

getHeaders

public String[] getHeaders(String headerName)
Returns all of the values of the specified header name.

Parameters:
headerName - the name of the header to find.
Returns:
the values of the headers.


Copyright © 2010 Eric Daugherty. All Rights Reserved.