Save This Page
Home » apache-tomcat-6.0.16-src » javax » mail » [javadoc | source]
javax.mail
abstract public class: Message [javadoc | source]
java.lang.Object
   javax.mail.Message

All Implemented Interfaces:
    Part

Direct Known Subclasses:
    SimpleTextMessage

Nested Class Summary:
public static class  Message.RecipientType  Enumeration of types of recipients allowed by the Message class. 
Field Summary
protected  int msgnum    The index of a message withing its folder, or zero if the message was not retrieved from a folder. 
protected  boolean expunged    True if this message has been expunged from the Store. 
protected  Folder folder    The Folder that contains this message, or null if it was not obtained from a folder. 
protected  Session session    The Session associated with this message. 
Constructor:
 protected Message() 
 protected Message(Session session) 
    Constructor initializing the session; intended to by used by client created instances.
    Parameters:
    session - the session associated with this message
 protected Message(Folder folder,
    int msgnum) 
    Constructor initializing folder and message msgnum; intended to be used by implementations of Folder.
    Parameters:
    folder - the folder that contains the message
    msgnum - the message index within the folder
Method from javax.mail.Message Summary:
addFrom,   addRecipient,   addRecipients,   getAllRecipients,   getFlags,   getFolder,   getFrom,   getMessageNumber,   getReceivedDate,   getRecipients,   getReplyTo,   getSentDate,   getSubject,   isExpunged,   isSet,   match,   reply,   saveChanges,   setExpunged,   setFlag,   setFlags,   setFrom,   setFrom,   setMessageNumber,   setRecipient,   setRecipients,   setReplyTo,   setSentDate,   setSubject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.mail.Message Detail:
 abstract public  void addFrom(Address[] addresses) throws MessagingException
    Add multiple addresses to the "From" header.
 public  void addRecipient(Message.RecipientType type,
    Address address) throws MessagingException 
    Add a recipent of a specified type.
 abstract public  void addRecipients(Message.RecipientType type,
    Address[] addresses) throws MessagingException
    Add recipents of a specified type.
 public Address[] getAllRecipients() throws MessagingException 
    Get all recipients of this message. The default implementation extracts the To, Cc, and Bcc recipients using #getRecipients(javax.mail.Message.RecipientType) and then concatentates the results into a single array; it returns null if no headers are defined.
 abstract public Flags getFlags() throws MessagingException
    Return a copy the flags associated with this message.
 public Folder getFolder() 
    Return the folder containing this message. If this is a new or nested message then this method returns null.
 abstract public Address[] getFrom() throws MessagingException
    Return the "From" header indicating the identity of the person who the message is from; in some circumstances this may be different to the actual sender.
 public int getMessageNumber() 
    Return the message number for this Message. This number refers to the relative position of this message in a Folder; the message number for any given message can change during a seesion if the Folder is expunged. Message numbers for messages in a folder start at one; the value zero indicates that this message does not belong to a folder.
 abstract public Date getReceivedDate() throws MessagingException
    Return the date this message was received.
 abstract public Address[] getRecipients(Message.RecipientType type) throws MessagingException
    Get all recipients of the given type.
 public Address[] getReplyTo() throws MessagingException 
    Get the addresses to which replies should be directed.

    As the most common behavior is to return to sender, the default implementation simply calls #getFrom() .

 abstract public Date getSentDate() throws MessagingException
    Return the date that this message was sent.
 abstract public String getSubject() throws MessagingException
    Get the subject for this message.
 public boolean isExpunged() 
    Checks to see if this message has been expunged. If true, all methods other than #getMessageNumber() are invalid.
 public boolean isSet(Flags.Flag flag) throws MessagingException 
    Check whether the supplied flag is set. The default implementation checks the flags returned by #getFlags() .
 public boolean match(SearchTerm term) throws MessagingException 
    Apply the specified search criteria to this message
 abstract public Message reply(boolean replyToAll) throws MessagingException
    Create a new message suitable as a reply to this message with all headers set up appropriately. The message body will be empty.

    if replyToAll is set then the new message will be addressed to all recipients of this message; otherwise the reply will be addressed only to the sender as returned by #getReplyTo() .

    The subject field will be initialized with the subject field from the orginal message; the text "Re:" will be prepended unless it is already present.

 abstract public  void saveChanges() throws MessagingException
    To ensure changes are saved to the store, this message should be invoked before its containing folder is closed. Implementations may save modifications immediately but are free to defer such updates to they may be sent to the server in one batch; if saveChanges is not called then such changes may not be made permanent.
 protected  void setExpunged(boolean expunged) 
    Set the expunged flag for this message.
 public  void setFlag(Flags.Flag flag,
    boolean set) throws MessagingException 
 abstract public  void setFlags(Flags flags,
    boolean set) throws MessagingException
    Set the flags specified to the supplied value; flags not included in the supplied Flags parameter are not affected.
 abstract public  void setFrom() throws MessagingException
    Set the "From" header for this message to the value of the "mail.user" property, of if that property is not set, to the value of the system property "user.name"
 abstract public  void setFrom(Address address) throws MessagingException
    Set the "From" header to the supplied address.
 protected  void setMessageNumber(int number) 
    Set the message number for this Message. This must be invoked by implementation classes when the message number changes.
 public  void setRecipient(Message.RecipientType type,
    Address address) throws MessagingException 
    Set the list of recipients for the specified type to a single address.
 abstract public  void setRecipients(Message.RecipientType type,
    Address[] addresses) throws MessagingException
    Set the list of recipients for the specified type.
 public  void setReplyTo(Address[] addresses) throws MessagingException 
    Set the addresses to which replies should be directed.

    The default implementation throws a MethodNotSupportedException.

 abstract public  void setSentDate(Date sent) throws MessagingException
    Set the date this message was sent.
 abstract public  void setSubject(String subject) throws MessagingException
    Set the subject of this message