oracle.ifs.adk.mail
Class IfsMessage


java.lang.Object

  |

  +--oracle.ifs.adk.mail.IfsMessage


public final class IfsMessage
extends java.lang.Object

An IfsMessage represents an iFS e-mail message.

This is part of the ADK to provide an easy to use API for iFS e-mail. The purpose of this class is to provide a mean to construct an iFS e-mail message programmatically.


Field Summary
static java.lang.String ASCII_CHARSET
          The default character set that uses only 7-bit characters.
static java.lang.String LATIN1_CHARSET
          The widely-used character set that is the superset of the ASCII character set.
 
Constructor Summary
IfsMessage(LibrarySession session)
          Constructor.
IfsMessage(LibrarySession session, FolderPathResolver resolver, Folder outbox, DirectoryUser sender)
          Constructor.
 
Method Summary
 void attach(Document doc)
          Attach a document.
 void attach(Document[] doc)
          Attach an array of documents.
 void attach(java.lang.String path)
          Attach a document.
 void attach(java.lang.String[] path)
          Attach an array of documents.
 oracle.ifs.protocols.email.beans.Message createMessage(boolean create)
          Gets the internal representation of the message.
 void send()
          Sends out the email message.
static void sendMessage(LibrarySession session, java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String subject, java.io.InputStream body)
          Send a message.
static void sendMessage(LibrarySession session, java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String subject, java.io.InputStream body, Document[] attachments)
          Send a message.
static void sendMessage(LibrarySession session, java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String subject, java.io.Reader body)
          Send a message.
static void sendMessage(LibrarySession session, java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String subject, java.io.Reader body, Document[] attachments)
          Send a message.
static void sendMessage(LibrarySession session, java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String subject, java.lang.String body)
          Send a message.
static void sendMessage(LibrarySession session, java.lang.String[] to, java.lang.String[] cc, java.lang.String[] bcc, java.lang.String subject, java.lang.String body, Document[] attachments)
          Send a message.
 void setAlternativeBodies(oracle.ifs.adk.mail.IfsMessage.MimeBodyPart[] body)
          Sets the body of the message with a multipart alternative body.
 void setBccHeader(java.lang.String bcc)
          Sets the Bcc header of the message.
 void setBccHeader(java.lang.String[] bcc)
          Sets the Bcc header of the message.
 void setBody(Document doc)
          Sets the body of the message.
 void setBody(java.io.InputStream in)
          Sets the body of the message.
 void setBody(java.io.InputStream in, java.lang.String contentType)
          Sets the body of the message and the content type of the body.
 void setBody(java.io.InputStream in, java.lang.String contentType, java.lang.String charset)
          Sets the body of the message, and the content type and the character set of the body.
 void setBody(java.io.Reader in)
          Sets the body of the message.
 void setBody(java.io.Reader in, java.lang.String contentType)
          Sets the body of the message and the content type of the body.
 void setBody(java.io.Reader in, java.lang.String contentType, java.lang.String charset)
          Sets the body of the message, and the content type and the character set of the body.
 void setBody(java.lang.String body)
          Sets the body of the message.
 void setBody(java.lang.String body, java.lang.String contentType)
          Sets the body of the message and the content type of the body.
 void setBody(java.lang.String body, java.lang.String contentType, java.lang.String charset)
          Sets the body of the message, and the content type and the character set of the body.
 void setCcHeader(java.lang.String cc)
          Sets the Cc header of the message.
 void setCcHeader(java.lang.String[] cc)
          Sets the Cc header of the message.
 void setCharset(java.lang.String charset)
          Sets the character set of the message body of a single body message.
 void setContentType(java.lang.String contentType)
          Sets the content type of the message body of a single body message.
 void setFromHeader(DirectoryUser sender)
          Sets the From header of the message.
 void setFromHeader(java.lang.String from)
          Sets the From header of the message.
 void setFromHeader(java.lang.String[] from)
          Sets the From header of the message.
 void setInReplyToHeader(oracle.ifs.protocols.email.beans.Message msg)
          Sets the In-Reply-To header of the message.
 void setMixedBodies(oracle.ifs.adk.mail.IfsMessage.MimeBodyPart[] body)
          Sets the body of the message with a multipart mixed body.
 void setReplyToHeader(java.lang.String replyTo)
          Sets the Reply-To header of the message.
 void setReplyToHeader(java.lang.String[] replyTo)
          Sets the Reply-To header of the message.
 void setSenderHeader(DirectoryUser sender)
          Sets the sender of the message.
 void setSubject(java.lang.String subject)
          Sets the subject of the message.
 void setToHeader(java.lang.String to)
          Sets the To header of the message.
 void setToHeader(java.lang.String[] to)
          Sets the To header of the message.
 

Field Detail


ASCII_CHARSET


public static final java.lang.String ASCII_CHARSET
The default character set that uses only 7-bit characters.

LATIN1_CHARSET


public static final java.lang.String LATIN1_CHARSET
The widely-used character set that is the superset of the ASCII character set. This can have 8-bit characters.
Constructor Detail

IfsMessage


public IfsMessage(LibrarySession session)
           throws IfsException
Constructor.
Parameters:
session - The LibrarySession object. This argument cannot be null.
Throws:
IfsException - if operation failed
See Also:
LibrarySession

IfsMessage


public IfsMessage(LibrarySession session,
                  FolderPathResolver resolver,
                  Folder outbox,
                  DirectoryUser sender)
           throws IfsException
Constructor.
Parameters:
session - The LibrarySession object. This argument cannot be null.
resolver - The FolderPathResolver object. This argument can be null.
outbox - The Mailbox object representing the mailbox for outbound email messages. This argument can be null.
sender - The DirectoryUser object representing the sender of the message. This argument can be null.
Throws:
IfsException - if operation failed
See Also:
LibrarySession, Mailbox
Method Detail

send


public void send()
          throws IfsException
Sends out the email message.

The email message is not fully constructed until right before it is sent. Therefore it is possible for the application developer to modify the message object before this method is called. However, after the method is called, all subsequent send message will send out the constructed email message that does not accept any further modifications.

Throws:
IfsException - if operation failed

setSenderHeader


public void setSenderHeader(DirectoryUser sender)
                     throws IfsException
Sets the sender of the message.
Parameters:
sender - The DiretoryUser object representing the sender. The sender's email address will be used in either the From header or the Sender header.
Throws:
IfsException - if operation failed
See Also:
DirectoryUser

setFromHeader


public void setFromHeader(DirectoryUser sender)
                   throws IfsException
Sets the From header of the message.
Parameters:
sender - The DiretoryUser object representing the user with the email address for the From header.
Throws:
IfsException - if operation failed
See Also:
DirectoryUser

setFromHeader


public void setFromHeader(java.lang.String from)
Sets the From header of the message.
Parameters:
from - The String with the email address of the user for the From header.

setFromHeader


public void setFromHeader(java.lang.String[] from)
Sets the From header of the message.
Parameters:
sender - The array of String with the email addresses of the users for the From header.

setToHeader


public void setToHeader(java.lang.String to)
Sets the To header of the message.
Parameters:
to - The String with the email addresses of the user for the To header.

setToHeader


public void setToHeader(java.lang.String[] to)
Sets the To header of the message.
Parameters:
sender - The array of String with the email addresses of the users for the To header.

setCcHeader


public void setCcHeader(java.lang.String cc)
Sets the Cc header of the message.
Parameters:
cc - The String with the email addresses of the user for the Cc header.

setCcHeader


public void setCcHeader(java.lang.String[] cc)
Sets the Cc header of the message.
Parameters:
cc - The array of String with the email addresses of the users for the Cc header.

setBccHeader


public void setBccHeader(java.lang.String bcc)
Sets the Bcc header of the message.
Parameters:
bcc - The String with the email addresses of the user for the bcc header.

setBccHeader


public void setBccHeader(java.lang.String[] bcc)
Sets the Bcc header of the message.
Parameters:
bcc - The array of String with the email addresses of the users for the Bcc header.

setReplyToHeader


public void setReplyToHeader(java.lang.String replyTo)
Sets the Reply-To header of the message.
Parameters:
replyTo - The String with the email address of the user for the Reply-To header.

setReplyToHeader


public void setReplyToHeader(java.lang.String[] replyTo)
Sets the Reply-To header of the message.
Parameters:
replyTo - The array of String with the email addresses of the users for the Reply-To header.

setInReplyToHeader


public void setInReplyToHeader(oracle.ifs.protocols.email.beans.Message msg)
                        throws IfsException
Sets the In-Reply-To header of the message.
Parameters:
msg - The Message object representing the email message to which this particular message is replying.
Throws:
IfsException - if operation failed
See Also:
Message

setSubject


public void setSubject(java.lang.String subject)
Sets the subject of the message.
Parameters:
subject - The String that represents the subject of the email message.

setCharset


public void setCharset(java.lang.String charset)
Sets the character set of the message body of a single body message.

To set the character set of the body parts of a multipart body, each of the body part has to be set individually. If character set is not set, the default US-ASCII is assumed (rfc2045).

Parameters:
charset - The String that represents the character set of the email message.

setContentType


public void setContentType(java.lang.String contentType)
Sets the content type of the message body of a single body message.

To set the content type of the body parts of a multipart body, each of the body part has to be set individually. If content type is not set, the default text/plain is assumed (rfc2045).

Parameters:
contentType - The String that represents the content set of the email message.

setBody


public void setBody(java.lang.String body)
Sets the body of the message.
Parameters:
body - The body in a String object.

setBody


public void setBody(java.io.Reader in)
Sets the body of the message.
Parameters:
body - The body in a Reader object.
See Also:
Reader

setBody


public void setBody(java.io.InputStream in)
Sets the body of the message.
Parameters:
body - The body in an InputStream object.
See Also:
InputStream

setBody


public void setBody(java.lang.String body,
                    java.lang.String contentType)
Sets the body of the message and the content type of the body.
Parameters:
body - The body in a String object.
contentType - The content type of the body.

setBody


public void setBody(java.io.InputStream in,
                    java.lang.String contentType)
Sets the body of the message and the content type of the body.
Parameters:
in - The body in an InputStream object.
contentType - The content type of the body.
See Also:
InputStream

setBody


public void setBody(java.io.Reader in,
                    java.lang.String contentType)
Sets the body of the message and the content type of the body.
Parameters:
in - The body in a Reader object.
contentType - The content type of the body.
See Also:
Reader

setBody


public void setBody(java.lang.String body,
                    java.lang.String contentType,
                    java.lang.String charset)
Sets the body of the message, and the content type and the character set of the body.
Parameters:
in - The body in a String object.
contentType - The content type of the body.
charset - The character set of the body.

setBody


public void setBody(java.io.InputStream in,
                    java.lang.String contentType,
                    java.lang.String charset)
Sets the body of the message, and the content type and the character set of the body.
Parameters:
in - The body in a InputStream object.
contentType - The content type of the body.
charset - The character set of the body.
See Also:
InputStream

setBody


public void setBody(java.io.Reader in,
                    java.lang.String contentType,
                    java.lang.String charset)
Sets the body of the message, and the content type and the character set of the body.
Parameters:
in - The body in a Reader object.
contentType - The content type of the body.
charset - The character set of the body.
See Also:
Reader

setBody


public void setBody(Document doc)
             throws IfsException
Sets the body of the message.
Parameters:
doc - The Document to be used as the body.
Throws:
IfsException - if operation failed
See Also:
Document

setAlternativeBodies


public void setAlternativeBodies(oracle.ifs.adk.mail.IfsMessage.MimeBodyPart[] body)
Sets the body of the message with a multipart alternative body.

If only one element is in the parameter, then this method has the same effect of useing setBody(MimeBodyPart body). The content type of the message is always multipart/alternative if the message does not have attachments. Otherwise, the message will be of content type multipart/mixed with a nested multipart/alternative message. A multipart/alternative body is a body of multiple body parts of the same content but in different formats. A compatible client should choose the most appropriate format to display the message to the user.

Parameters:
body - The array of MimeBodyPart objects representing the alternative bodies.
See Also:
IfsMessage.MimeBodyPart

setMixedBodies


public void setMixedBodies(oracle.ifs.adk.mail.IfsMessage.MimeBodyPart[] body)
Sets the body of the message with a multipart mixed body.

If only one element is in the parameter, then this method has the same effect of useing setBody(MimeBodyPart body). The multipart/mixed content type is the most general content type for any multipart message or any message with attachments. The client is free to choose the method to display the message. Generally, the different body parts are treated as different part of the message (same as attachment).

Parameters:
body - The array of MimeBodyPart objects representing the mixed bodies.
See Also:
IfsMessage.MimeBodyPart

attach


public void attach(Document doc)
Attach a document.

The content type of the message with attachments is always multipart/mixed.

Parameters:
doc - The Document to attach.
See Also:
Document

attach


public void attach(java.lang.String path)
            throws IfsException
Attach a document.

The content type of the message with attachments is always multipart/mixed.

Parameters:
path - The path of the Document to attach.
Throws:
IfsException - thrown when the path is invalid
See Also:
Document

attach


public void attach(Document[] doc)
Attach an array of documents.

The content type of the message with attachments is always multipart/mixed.

Parameters:
doc - The array of Document objects to attach.
See Also:
Document

attach


public void attach(java.lang.String[] path)
            throws IfsException
Attach an array of documents.

The content type of the message with attachments is always multipart/mixed.

Parameters:
path - The array of paths pointing to the Document objects to attach.
Throws:
IfsException - thrown when one of the path is invalid.
See Also:
Document

sendMessage


public static void sendMessage(LibrarySession session,
                               java.lang.String[] to,
                               java.lang.String[] cc,
                               java.lang.String[] bcc,
                               java.lang.String subject,
                               java.lang.String body)
                        throws IfsException
Send a message.

This is a convenience method for sending email. The alternative way to send an email is to use the individual methods on the IfsMessage object.

Parameters:
session - The LibrarySession.
to - The email addressses to which the message is sent.
cc - The email addressses to which the message is copied.
bcc - The email addressses to which the message is blind-copied.
subject - The subject of the email.
body - The email body as a String.
Throws:
IfsException - if operation failed
See Also:
LibrarySession

sendMessage


public static void sendMessage(LibrarySession session,
                               java.lang.String[] to,
                               java.lang.String[] cc,
                               java.lang.String[] bcc,
                               java.lang.String subject,
                               java.io.InputStream body)
                        throws IfsException
Send a message.

This is a convenience method for sending email. The alternative way to send an email is to use the individual methods on the IfsMessage object.

Parameters:
session - The LibrarySession.
to - The email addressses to which the message is sent.
cc - The email addressses to which the message is copied.
bcc - The email addressses to which the message is blind-copied.
subject - The subject of the email.
body - The email body as an InputStream.
Throws:
IfsException - if operation failed
See Also:
LibrarySession

sendMessage


public static void sendMessage(LibrarySession session,
                               java.lang.String[] to,
                               java.lang.String[] cc,
                               java.lang.String[] bcc,
                               java.lang.String subject,
                               java.io.Reader body)
                        throws IfsException
Send a message.

This is a convenience method for sending email. The alternative way to send an email is to use the individual methods on the IfsMessage object.

Parameters:
session - The LibrarySession.
to - The email addressses to which the message is sent.
cc - The email addressses to which the message is copied.
bcc - The email addressses to which the message is blind-copied.
subject - The subject of the email.
body - The email body as a Reader.
Throws:
IfsException - if operation failed.
See Also:
LibrarySession

sendMessage


public static void sendMessage(LibrarySession session,
                               java.lang.String[] to,
                               java.lang.String[] cc,
                               java.lang.String[] bcc,
                               java.lang.String subject,
                               java.lang.String body,
                               Document[] attachments)
                        throws IfsException
Send a message.

This is a convenience method for sending email. The alternative way to send an email is to use the individual methods on the IfsMessage object.

Parameters:
session - The LibrarySession.
to - The email addressses to which the message is sent.
cc - The email addressses to which the message is copied.
bcc - The email addressses to which the message is blind-copied.
subject - The subject of the email.
body - The email body as a String.
attachments - The email attachments in an array of Document.
Throws:
IfsException - if operation failed
See Also:
IfsMessage

sendMessage


public static void sendMessage(LibrarySession session,
                               java.lang.String[] to,
                               java.lang.String[] cc,
                               java.lang.String[] bcc,
                               java.lang.String subject,
                               java.io.InputStream body,
                               Document[] attachments)
                        throws IfsException
Send a message.

This is a convenience method for sending email. The alternative way to send an email is to use the individual methods on the IfsMessage object.

Parameters:
session - The LibrarySession.
to - The email addressses to which the message is sent.
cc - The email addressses to which the message is copied.
bcc - The email addressses to which the message is blind-copied.
subject - The subject of the email.
body - The email body as an InputStream.
attachments - The email attachments in an array of Document.
Throws:
IfsException - if operation failed
See Also:
IfsMessage

sendMessage


public static void sendMessage(LibrarySession session,
                               java.lang.String[] to,
                               java.lang.String[] cc,
                               java.lang.String[] bcc,
                               java.lang.String subject,
                               java.io.Reader body,
                               Document[] attachments)
                        throws IfsException
Send a message.

This is a convenience method for sending email. The alternative way to send an email is to use the individual methods on the IfsMessage object.

Parameters:
session - The LibrarySession.
to - The email addressses to which the message is sent.
cc - The email addressses to which the message is copied.
bcc - The email addressses to which the message is blind-copied.
subject - The subject of the email.
body - The email body as a Reader.
attachments - The email attachments in an array of Document.
Throws:
IfsException - if operation failed
See Also:
IfsMessage

createMessage


public oracle.ifs.protocols.email.beans.Message createMessage(boolean create)
                                                       throws IfsException
Gets the internal representation of the message.

This is basically a snapshot of the message object. This will return a copy of the Message object created with the current state. All subsequent changes to the IfsMessage object will not be reflected in the copy returned. When the IfsMessage is sent, a new Message object is created.

Parameters:
create - Re-create the Message object even if the state has not been changed.
Returns:
return a copy of the underlying Message object.
Throws:
IfsException - if operation failed
See Also:
Message