| java.lang.Object | |
| ↳ | com.google.code.javax.mail.Message |
Known Direct Subclasses
|
Known Indirect Subclasses
|
This class models an email message. This is an abstract class. Subclasses provide actual implementations.
Message implements the Part interface. Message contains a set of attributes and a "content". Messages within a folder also have a set of flags that describe its state within the folder.
Message defines some new attributes in addition to those defined
in the Part interface. These attributes specify meta-data
for the message - i.e., addressing and descriptive information about
the message.
Message objects are obtained either from a GmailFolder or by constructing a new Message object of the appropriate subclass. Messages that have been received are normally retrieved from a folder named "INBOX".
A Message object obtained from a folder is just a lightweight
reference to the actual message. The Message is 'lazily' filled
up (on demand) when each item is requested from the message. Note
that certain folder implementations may return Message objects that
are pre-filled with certain user-specified items.
To send a message, an appropriate subclass of Message (e.g.,
MimeMessage) is instantiated, the attributes and content are
filled in, and the message is sent using the Transport.send
method.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Message.RecipientType | This inner class defines the types of recipients allowed by the Message class. | ||||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.google.code.javax.mail.Part
| |||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| expunged | True if this message has been expunged. | ||||||||||
| folder | The containing folder, if this message is obtained from a folder | ||||||||||
| msgnum | The number of this message within its folder, or zero if the message was not retrieved from a folder. | ||||||||||
| session | The Session object for this Message | ||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
No-arg version of the constructor.
| |||||||||||
Constructor that takes a GmailFolder and a message number.
| |||||||||||
Constructor that takes a Session.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Add these addresses to the existing "From" attribute
| |||||||||||
Add this recipient address to the existing ones of the given type.
| |||||||||||
Add these recipient addresses to the existing ones of the given type.
| |||||||||||
Get all the recipient addresses for the message.
| |||||||||||
Returns a
Flags object containing the flags for
this message. | |||||||||||
Get the folder from which this message was obtained.
| |||||||||||
Returns the "From" attribute.
| |||||||||||
Get the Message number for this Message.
| |||||||||||
Get the date this message was received.
| |||||||||||
Get all the recipient addresses of the given type.
| |||||||||||
Get the addresses to which replies should be directed.
| |||||||||||
Get the date this message was sent.
| |||||||||||
Get the subject of this message.
| |||||||||||
Checks whether this message is expunged.
| |||||||||||
Check whether the flag specified in the
flag
argument is set in this message. | |||||||||||
Apply the specified Search criterion to this message.
| |||||||||||
Get a new Message suitable for a reply to this message.
| |||||||||||
Save any changes made to this message into the message-store
when the containing folder is closed, if the message is contained
in a folder.
| |||||||||||
Set the specified flag on this message to the specified value.
| |||||||||||
Set the specified flags on this message to the specified value.
| |||||||||||
Set the "From" attribute in this Message.
| |||||||||||
Set the "From" attribute in this Message.
| |||||||||||
Set the recipient address.
| |||||||||||
Set the recipient addresses.
| |||||||||||
Set the addresses to which replies should be directed.
| |||||||||||
Set the sent date of this message.
| |||||||||||
Set the subject of this message.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Sets the expunged flag for this Message.
| |||||||||||
Set the Message number for this Message.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.google.code.javax.mail.Part
| |||||||||||
True if this message has been expunged.
The number of this message within its folder, or zero if the message was not retrieved from a folder.
No-arg version of the constructor.
Constructor that takes a GmailFolder and a message number. Used by GmailFolder implementations.
| folder | Containing folder |
|---|---|
| msgnum | This message's sequence number within this folder |
Constructor that takes a Session. Used for client created Message objects.
| session | A Session object |
|---|
Add these addresses to the existing "From" attribute
| addresses | The senders |
|---|
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Add this recipient address to the existing ones of the given type.
The default implementation uses the addRecipients method.
| type | The recipient type |
|---|---|
| address | The address |
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| MessagingException |
Add these recipient addresses to the existing ones of the given type.
| type | The recipient type |
|---|---|
| addresses | The addresses |
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Get all the recipient addresses for the message.
The default implementation extracts the TO, CC, and BCC
recipients using the getRecipients method.
This method returns null if none of the recipient
headers are present in this message. It may Return an empty array
if any recipient header is present, but contains no addresses.
| MessagingException |
|---|
Returns a Flags object containing the flags for
this message.
Modifying any of the flags in this returned Flags object will
not affect the flags of this message. Use setFlags()
to do that.
| MessagingException |
|---|
setFlags(Flags, boolean)Get the folder from which this message was obtained. If this is a new message or nested message, this method returns null.
Returns the "From" attribute. The "From" attribute contains the identity of the person(s) who wished this message to be sent.
In certain implementations, this may be different from the entity that actually sent the message.
This method returns null if this attribute
is not present in this message. Returns an empty array if
this attribute is present, but contains no addresses.
| MessagingException |
|---|
Get the Message number for this Message. A Message object's message number is the relative position of this Message in its GmailFolder. Note that the message number for a particular Message can change during a session if other messages in the GmailFolder are deleted and expunged.
Valid message numbers start at 1. Messages that do not belong to any folder (like newly composed or derived messages) have 0 as their message number.
Get the date this message was received.
| MessagingException |
|---|
Get all the recipient addresses of the given type.
This method returns null if no recipients of
the given type are present in this message. It may return an
empty array if the header is present, but contains no addresses.
| type | The recipient type |
|---|
| MessagingException |
|---|
Get the addresses to which replies should be directed. This will usually be the sender of the message, but some messages may direct replies to a different address.
The default implementation simply calls the getFrom
method.
This method returns null if the corresponding
header is not present. Returns an empty array if the header
is present, but contains no addresses.
| MessagingException |
|---|
Get the date this message was sent.
| MessagingException |
|---|
Checks whether this message is expunged. All other methods except
getMessageNumber() are invalid on an expunged
Message object.
Messages that are expunged due to an explict expunge()
request on the containing GmailFolder are removed from the GmailFolder
immediately. Messages that are externally expunged by another source
are marked "expunged" and return true for the isExpunged() method,
but they are not removed from the GmailFolder until an explicit
expunge() is done on the GmailFolder.
See the description of expunge() for more details on
expunge handling.
Check whether the flag specified in the flag
argument is set in this message.
The default implementation uses getFlags.
| flag | The flag |
|---|
| MessagingException |
|---|
Apply the specified Search criterion to this message.
| term | The Search criterion |
|---|
| MessagingException |
|---|
Get a new Message suitable for a reply to this message. The new Message will have its attributes and headers set up appropriately. Note that this new message object will be empty, that is, it will not have a "content". These will have to be suitably filled in by the client.
If replyToAll is set, the new Message will be addressed
to all recipients of this message. Otherwise, the reply will be
addressed to only the sender of this message (using the value
of the getReplyTo method).
The "Subject" field is filled in with the original subject prefixed with "Re:" (unless it already starts with "Re:").
The reply message will use the same session as this message.
| replyToAll | Reply should be sent to all recipients of this message |
|---|
| MessagingException |
|---|
Save any changes made to this message into the message-store when the containing folder is closed, if the message is contained in a folder. (Some implementations may save the changes immediately.) Update any header fields to be consistent with the changed message contents. If any part of a message's headers or contents are changed, saveChanges must be called to ensure that those changes are permanent. If saveChanges is not called, any such modifications may or may not be saved, depending on the message store and folder implementation.
Messages obtained from folders opened READ_ONLY should not be modified and saveChanges should not be called on such messages.
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
|---|---|
| IllegalWriteException | if the underlying implementation does not support modification of existing values. |
| MessagingException |
Set the specified flag on this message to the specified value.
This will result in a MessageChangedEvent being
delivered to any MessageChangedListener registered on this
Message's containing folder.
The default implementation uses the setFlags method.
| flag | Flags.Flag object containing the flag to be set |
|---|---|
| set | The value to be set |
| IllegalWriteException | if the underlying implementation does not support modification of existing values. |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Set the specified flags on this message to the specified value.
Note that any flags in this message that are not specified in
the given Flags object are unaffected.
This will result in a MessageChangedEvent being
delivered to any MessageChangedListener registered on this
Message's containing folder.
| flag | Flags object containing the flags to be set |
|---|---|
| set | The value to be set |
| IllegalWriteException | if the underlying implementation does not support modification of existing values. |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Set the "From" attribute in this Message. The value of this attribute is obtained from the property "mail.user". If this property is absent, the system property "user.name" is used.
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Set the "From" attribute in this Message.
| address | The sender |
|---|
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Set the recipient address. All addresses of the specified type are replaced by the address parameter.
The default implementation uses the setRecipients method.
| type | The recipient type |
|---|---|
| address | The address |
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| MessagingException |
Set the recipient addresses. All addresses of the specified type are replaced by the addresses parameter.
| type | The recipient type |
|---|---|
| addresses | The addresses |
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Set the addresses to which replies should be directed. (Normally only a single address will be specified.) Not all message types allow this to be specified separately from the sender of the message.
The default implementation provided here just throws the MethodNotSupportedException.
| addresses | Addresses to which replies should be directed |
|---|
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MethodNotSupportedException | if the underlying implementation does not support setting this attribute |
| MessagingException |
Set the sent date of this message.
| date | The sent date of this message |
|---|
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Set the subject of this message.
| subject | The subject |
|---|
| IllegalWriteException | if the underlying implementation does not support modification of existing values |
|---|---|
| IllegalStateException | if this message is obtained from a READ_ONLY folder. |
| MessagingException |
Sets the expunged flag for this Message. This method is to be used only by the implementation classes.
| expunged | The expunged flag |
|---|
Set the Message number for this Message. This method is invoked only by the implementation classes.
| msgnum |
|---|