|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.srv.mail.AgoMailMessage
Provides a simple API to access a received email message. Provides methods to access the commonly used hearders of ASCII and MIME email, and to access file attachments in MIME messages.
For a detailed inspection of MIME messages, call the getMIMEPart()
method to get an AgoMIMEPart object representing the mail message.
The AgoMIMEPart object provides access to everything in the message.
Constructor Summary | |
AgoMailMessage(AgoMIMEPart message)
The constructor for the AgoMailMessage class. |
Method Summary | |
Enumeration |
fieldBccElements()
Returns an Enumeration of the bcc field of the mail message. |
Enumeration |
fieldCcElements()
Returns an Enumeration of the cc field of the mail message. |
String |
fieldDate()
Returns the Date field of the message or null if there is no Date field. |
AgoMailAddressMailbox |
fieldFrom()
Returns the From field of the message or null if there is no From field. |
Enumeration |
fieldFromElements()
Returns an Enumeration of the From field of the message. |
String |
fieldMessageID()
Returns the MessageID field of the message or null if there is no MessageID field. |
String |
fieldOrganization()
Returns the Organization field of the message or null if there is no Organizatin field. |
Enumeration |
fieldReplyToElements()
Returns an Enumeration of the Reply-To field of the message. |
AgoMailAddressMailbox |
fieldSender()
Returns the Sender field of the message or null if there is no Sender field. |
String |
fieldSubject()
Returns the Subject field of the message or null if there is no Subject. |
Enumeration |
fieldToElements()
Returns an Enumeration of the To field of the message. |
Enumeration |
fileAttachments()
Returns an Enumeration of AgoFileAttachmentInputStream objects for the
file attachments. |
AgoMIMEPart |
getMIMEPart()
Returns an AgoMIMEPart object that represents the entire message. |
String |
messageText()
Attempts to return the body of the message as a String. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public AgoMailMessage(AgoMIMEPart message)
message
- the email message.Method Detail |
public AgoMIMEPart getMIMEPart()
Use this method to examine in detail the message headers or any of the parts of a MIME message. If the message is a multipart message, the AgoMIMEPart returned is in the form of a tree structure with subparts.
AgoMIMEPart mimePart = msg.getMIMEPart();
public String fieldSubject()
String subject = msg.fieldSubject();
public String fieldDate()
The returned date is in String form as it is found in the message. It is not a Date object.
String dt = msg.fieldDate();
public AgoMailAddressMailbox fieldFrom()
AgoMailAddressMailbox
.
The AgoMailAddressMailbox methods access the name and address parts of the From field.It is possible to have more than one From address in a message. This method returns only the first one. The fieldFromElements() method can be used to see all the From addresses.
AgoMailAddressMailbox from = msg.fieldFrom();
AgoMailMessage.fieldFromElements()
public Enumeration fieldFromElements()
AgoMailAddressMailbox
objects.
If there is no From field, an empty Enumeration is returned.Normally a From field contains a single mailbox. It is possible, however, for a Sender to be specified, and for a message to include multiple From entries. In a conforming RFC 822 message, if there is more than one From address, there must be a Sender field.
Enumeration from = msg.fieldFromElements(); while (from.hasMoreElements()) { AgoMailAddressMailbox mb = (AgoMailAddressMailbox)from.nextElement(); // work with mailbox mb here }
public AgoMailAddressMailbox fieldSender()
AgoMailAddressMailbox
.
The AgoMailAddressMailbox provides methods to access the name
and address parts of the Sender field.
The Sender field is not commonly used and is often confused with the From field.
The From field is used to describe the author of the message.
The sender should describe who actually sent the message.
The author and the sender are usually the same person.
However, they would be different in the case of an assistant sending mail
for a boss, or a group of people authoring a message which is obviously
sent by just one member of the group. When a Sender is specified,
it is possible for the message to have multiple entries in
the From field (as specified in RFC 822).
The AgoMailMessage.fieldFromElements()
method exists for this uncommon situation.
AgoMailAddressMailbox sender = msg.fieldSender();
public Enumeration fieldReplyToElements()
AgoMailAddressMailbox
objects.
If there is no Reply-To field, an empty Enumeration is returned.Enumeration replyTo = msg.fieldReplyToElements(); while (replyTo.hasMoreElements()) { AgoMailAddressMailbox mb = (AgoMailAddressMailbox)replyTo.nextElement(); // work with mailbox mb here }
public Enumeration fieldToElements()
AgoMailAddressMailbox
objects. If there is no To field, an
empty Enumeration is returned.Enumeration to = msg.fieldToElements(); while (to.hasMoreElements()) { AgoMailAddressMailbox mb = (AgoMailAddressMailbox)to.nextElement(); // work with mailbox mb here }
public Enumeration fieldCcElements()
AgoMailAddressMailbox
objects.
If there is no cc field, an empty Enumeration is returned.Enumeration cc = msg.fieldCcElements(); while (cc.hasMoreElements()) { AgoMailAddressMailbox mb = (AgoMailAddressMailbox)cc.nextElement(); // work with mailbox mb here }
public Enumeration fieldBccElements()
AgoMailAddressMailbox
objects.
If there is no Bcc field, an empty Enumeration is returned.For a conforming RFC 822 message, the fieldBccElements always returns an empty Enumeration since mail should never be received with a Bcc field still in it.
Enumeration bcc = msg.fieldBccElements(); while (bcc.hasMoreElements()) { AgoMailAddressMailbox mb = (AgoMailAddressMailbox)bcc.nextElement(); // work with mailbox mb here }
public String fieldMessageID()
The MessageID is a long string which is unique to each message. It is of no interest unless except to track message threads and messages that reference other messages.
String mesgID = msg.fieldMessageID();
public String fieldOrganization()
String org = msg.fieldOrganization();
public String messageText() throws IOException
This method might be used to parse the text of a message to take some action based on the contents, for example, to look for a SUBSCRIBE command. But there are many formats of mail. It might be a plain ASCII message, it might be a MIME message with a single text/plain part. It is increasingly common to receive mail which is a multipart/alternative with a text/html and a text/plain part. This method returns a String representing the body of the message in plain text.
The messageText() method uses the following algorithm:
String msgText = msg.messageText();
public Enumeration fileAttachments() throws IOException
AgoFileAttachmentInputStream
objects for the
file attachments.File attachments returned by this method are defined as follows: If the message is of Content-Type application, the whole message is considered an attachment. If this is a multipart message, then any part that is an application, or has a Content-Disposition header whose value is attachment, is considered an attachment. This applies only to the top level of the message. attachments.
Enumeration attachments = msg.fileAttachments();
|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |