public abstract class Message extends java.lang.Object implements Part
Modifier and Type | Class and Description |
---|---|
static class |
Message.RecipientType
Enumeration of types of recipients allowed by the Message class.
|
Modifier and Type | Field and Description |
---|---|
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 int |
msgnum
The index of a message withing its folder, or zero if the message was not retrieved from a folder.
|
protected Session |
session
The
Session associated with this message. |
ATTACHMENT, INLINE
Modifier | Constructor and Description |
---|---|
protected |
Message()
Default constructor.
|
protected |
Message(Folder folder,
int msgnum)
Constructor initializing folder and message msgnum; intended to be used by implementations of Folder.
|
protected |
Message(Session session)
Constructor initializing the session; intended to by used by client created instances.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addFrom(Address[] addresses)
Add multiple addresses to the "From" header.
|
void |
addRecipient(Message.RecipientType type,
Address address)
Add a recipent of a specified type.
|
abstract void |
addRecipients(Message.RecipientType type,
Address[] addresses)
Add recipents of a specified type.
|
Address[] |
getAllRecipients()
Get all recipients of this message.
|
abstract Flags |
getFlags()
Return a copy the flags associated with this message.
|
Folder |
getFolder()
Return the folder containing this message.
|
abstract Address[] |
getFrom()
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.
|
int |
getMessageNumber()
Return the message number for this Message.
|
abstract java.util.Date |
getReceivedDate()
Return the date this message was received.
|
abstract Address[] |
getRecipients(Message.RecipientType type)
Get all recipients of the given type.
|
Address[] |
getReplyTo()
Get the addresses to which replies should be directed.
|
abstract java.util.Date |
getSentDate()
Return the date that this message was sent.
|
abstract java.lang.String |
getSubject()
Get the subject for this message.
|
boolean |
isExpunged()
Checks to see if this message has been expunged.
|
boolean |
isSet(Flags.Flag flag)
Check whether the supplied flag is set.
|
boolean |
match(SearchTerm term)
Apply the specified search criteria to this message
|
abstract Message |
reply(boolean replyToAll)
Create a new message suitable as a reply to this message with all headers set
up appropriately.
|
abstract void |
saveChanges()
To ensure changes are saved to the store, this message should be invoked
before its containing folder is closed.
|
protected void |
setExpunged(boolean expunged)
Set the expunged flag for this message.
|
void |
setFlag(Flags.Flag flag,
boolean set)
Set a flag to the supplied value.
|
abstract void |
setFlags(Flags flags,
boolean set)
Set the flags specified to the supplied value; flags not included in the
supplied
Flags parameter are not affected. |
abstract void |
setFrom()
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 void |
setFrom(Address address)
Set the "From" header to the supplied address.
|
protected void |
setMessageNumber(int number)
Set the message number for this Message.
|
void |
setRecipient(Message.RecipientType type,
Address address)
Set the list of recipients for the specified type to a single address.
|
abstract void |
setRecipients(Message.RecipientType type,
Address[] addresses)
Set the list of recipients for the specified type.
|
void |
setReplyTo(Address[] addresses)
Set the addresses to which replies should be directed.
|
abstract void |
setSentDate(java.util.Date sent)
Set the date this message was sent.
|
abstract void |
setSubject(java.lang.String subject)
Set the subject of this message
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addHeader, getAllHeaders, getContent, getContentType, getDataHandler, getDescription, getDisposition, getFileName, getHeader, getInputStream, getLineCount, getMatchingHeaders, getNonMatchingHeaders, getSize, isMimeType, removeHeader, setContent, setContent, setDataHandler, setDescription, setDisposition, setFileName, setHeader, setText, writeTo
protected int msgnum
protected boolean expunged
protected Folder folder
Folder
that contains this message, or null if it was not obtained from a folder.protected Message()
protected Message(Folder folder, int msgnum)
folder
- the folder that contains the messagemsgnum
- the message index within the folderprotected Message(Session session)
session
- the session associated with this messagepublic abstract Address[] getFrom() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract void setFrom() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract void setFrom(Address address) throws MessagingException
address
- the address of the person who the message is fromMessagingException
- if there was a problem accessing the storepublic abstract void addFrom(Address[] addresses) throws MessagingException
addresses
- the addresses to addMessagingException
- if there was a problem accessing the storepublic abstract Address[] getRecipients(Message.RecipientType type) throws MessagingException
type
- the type of recipient to getMessagingException
- if there was a problem accessing the storeMessage.RecipientType
public Address[] getAllRecipients() throws MessagingException
getRecipients(javax.mail.Message.RecipientType)
and then concatentates the results into a single array; it returns null if no headers are defined.MessagingException
- if there was a problem accessing the storepublic abstract void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
type
- the type of recipientaddresses
- the new addressesMessagingException
- if there was a problem accessing the storepublic void setRecipient(Message.RecipientType type, Address address) throws MessagingException
type
- the type of recipientaddress
- the new addressMessagingException
- if there was a problem accessing the storepublic abstract void addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
type
- the type of recipientaddresses
- the addresses to addMessagingException
- if there was a problem accessing the storepublic void addRecipient(Message.RecipientType type, Address address) throws MessagingException
type
- the type of recipientaddress
- the address to addMessagingException
- if there was a problem accessing the storepublic Address[] getReplyTo() throws MessagingException
getFrom()
.MessagingException
- if there was a problem accessing the storepublic void setReplyTo(Address[] addresses) throws MessagingException
addresses
- to which replies should be directedMessagingException
- if there was a problem accessing the storepublic abstract java.lang.String getSubject() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract void setSubject(java.lang.String subject) throws MessagingException
subject
- the subjectMessagingException
- if there was a problem accessing the storepublic abstract java.util.Date getSentDate() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract void setSentDate(java.util.Date sent) throws MessagingException
sent
- the date when this message was sentMessagingException
- if there was a problem accessing the storepublic abstract java.util.Date getReceivedDate() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract Flags getFlags() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic boolean isSet(Flags.Flag flag) throws MessagingException
getFlags()
.flag
- the flags to check forMessagingException
- if there was a problem accessing the storepublic abstract void setFlags(Flags flags, boolean set) throws MessagingException
Flags
parameter are not affected.flags
- the flags to modifyset
- the new value of those flagsMessagingException
- if there was a problem accessing the storepublic void setFlag(Flags.Flag flag, boolean set) throws MessagingException
setFlags(Flags, boolean)
.flag
- the flag to setset
- the value for that flagMessagingException
- if there was a problem accessing the storepublic int getMessageNumber()
protected void setMessageNumber(int number)
number
- the new message numberpublic Folder getFolder()
public boolean isExpunged()
getMessageNumber()
are invalid.protected void setExpunged(boolean expunged)
expunged
- true if this message has been expungedpublic abstract Message reply(boolean replyToAll) throws MessagingException
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.replyToAll
- if true, indciates the message should be addressed to all recipients not just the senderMessagingException
- if there was a problem accessing the storepublic abstract void saveChanges() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic boolean match(SearchTerm term) throws MessagingException
term
- the search criteriaMessagingException
- if there was a problem accessing the store