An abstract mail message, consisting of headers and content.
A message is retrieved from a folder, and is normally a lightweight
object that retrieves its properties on demand. Fetch profiles may be
used to prefetch certain properties of a message.
To send a message, an appropriate subclsass is instantiated, its
properties set, and it is then delivered via a transport using the
Transport.sendMessage
method.
addFrom
public abstract void addFrom(Address[] addresses)
throws MessagingException
Adds addresses to the identity of the person sending this message.
getAllRecipients
public Address[] getAllRecipients()
throws MessagingException
Returns all the recipient addresses in the message.
getFlags
public abstract Flags getFlags()
throws MessagingException
Returns the flags for this message.
Modifying any of these flags does not affect the message flags.
Use the
setFlags
method to change the message's flags.
getFolder
public Folder getFolder()
Returns the folder from which this message was obtained.
getFrom
public abstract Address[] getFrom()
throws MessagingException
Returns the identity of the person(s) who ordered the sending of
this message.
In certain implementations, this may be different from the entity that
actually sent the message.
getMessageNumber
public int getMessageNumber()
Returns the message number for this message within its folder.
getReceivedDate
public abstract Date getReceivedDate()
throws MessagingException
Returns the date this message was received.
getReplyTo
public Address[] getReplyTo()
throws MessagingException
Returns the addresses to which replies should be directed. This
defaults to the sender of the message.
getSentDate
public abstract Date getSentDate()
throws MessagingException
Returns the date this message was sent.
getSubject
public abstract String getSubject()
throws MessagingException
Returns the subject of this message.
isExpunged
public boolean isExpunged()
Indicates whether this message is expunged.
reply
public abstract Message reply(boolean replyToAll)
throws MessagingException
Returns a new message suitable for a reply to this message.
The new message will have its recipients set appropriately, but will
have no content.
The subject field is filled in with the original subject prefixed with
"Re:" (unless it already starts with "Re:").
replyToAll
- if the reply should be sent to all recipients of
this message
saveChanges
public abstract void saveChanges()
throws MessagingException
Save any changes made to this message into its underlying store, if
the message was obtained from a folder. The message may be saved
immediately or when its containing folder is closed.
This method ensures that any header fields are consistent with the
changed message contents.
setExpunged
protected void setExpunged(boolean expunged)
Sets the expunged flag for this message.
setFlag
public void setFlag(Flags.Flag flag,
boolean set)
throws MessagingException
Sets the specified flag on this message to the given value.
flag
- the flag to be setset
- the value to be set
setFlags
public abstract void setFlags(Flags flag,
boolean set)
throws MessagingException
Sets the specified flags on this message to the given value.
Any flags in this message that are not specified in the given flags
are unaffected.
flag
- the flags to be setset
- the value to be set
setFrom
public abstract void setFrom()
throws MessagingException
Sets the identity of the person sending this message, as obtained
from the property "mail.user".
If this property is absent, the system property "user.name" is used.
setFrom
public abstract void setFrom(Address address)
throws MessagingException
Sets the identity of the person sending this message.
setMessageNumber
protected void setMessageNumber(int msgnum)
Sets the message number for this message.
setReplyTo
public void setReplyTo(Address[] addresses)
throws MessagingException
Sets the addresses to which replies should be directed.
setSentDate
public abstract void setSentDate(Date date)
throws MessagingException
Sets the date this message was sent.
date
- the sent date of this message
setSubject
public abstract void setSubject(String subject)
throws MessagingException
Sets the subject of this message.