|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.mail Class Message
java.lang.Object javax.mail.Message
- All Implemented Interfaces:
- Part
- Direct Known Subclasses:
- MimeMessage
此类模拟电子邮件消息。这是一个抽象类。子类提供实际实现。
Message 实现 Part 接口。Message 包含一个属性集和一个 "content"。文件夹中的 Message 还包括一组标记,描述其在该文件夹中的状态。
除了在 Part
接口中定义的属性之外,Message 还定义了一些新属性。这些属性指定消息的元数据,即与消息有关的地址信息和描述性信息。
Message 对象可从 Folder 中获取,也可以通过构造相应子类的新 Message 对象获取。已接收的 Message 通常从名为 "INBOX" 的文件夹获取。
从文件夹获取的 Message 对象只是对实际消息的轻量级引用。当从该消息请求每个条目时,Message 是“延迟”填充的(按需)。注意,某些 Folder 实现可能返回预先填充了一些用户指定条目的 Message 对象。
要发送一条消息,需要实例化相应的 Message 子类(例如 MimeMessage),填充属性和内容,然后使用 Transport.send
方法发送该消息。
See also | javax.mail.Part |
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 Folder 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.
- Author:
- John Mani, Bill Shannon, Max Spivak
- See Also:
Part
Nested Class Summary | |
---|---|
static class |
Message.RecipientType
This inner class defines the types of recipients allowed by the Message class. |
Field Summary | |
---|---|
protected boolean |
expunged
True if this message has been expunged. |
protected Folder |
folder
The containing folder, if this message is obtained from a folder |
protected int |
msgnum
The number of this message within its folder, or zero if the message was not retrieved from a folder. |
protected Session |
session
The Session object for this Message |
Fields inherited from interface javax.mail.Part |
---|
ATTACHMENT, INLINE |
Constructor Summary | |
---|---|
protected |
Message()
No-arg version of the constructor. |
protected |
Message(Folder folder,
int msgnum)
Constructor that takes a Folder and a message number. |
protected |
Message(Session session)
Constructor that takes a Session. |
Method Summary | |
---|---|
abstract void |
addFrom(Address[] addresses)
Add these addresses to the existing "From" attribute |
void |
addRecipient(Message.RecipientType type,
Address address)
Add this recipient address to the existing ones of the given type. |
abstract void |
addRecipients(Message.RecipientType type,
Address[] addresses)
Add these recipient addresses to the existing ones of the given type. |
Address[] |
getAllRecipients()
Get all the recipient addresses for the message. |
abstract Flags |
getFlags()
Returns a Flags object containing the flags for
this message. |
Folder |
getFolder()
Get the folder from which this message was obtained. |
abstract Address[] |
getFrom()
Returns the "From" attribute. |
int |
getMessageNumber()
Get the Message number for this Message. |
abstract Date |
getReceivedDate()
Get the date this message was received. |
abstract Address[] |
getRecipients(Message.RecipientType type)
Get all the recipient addresses of the given type. |
Address[] |
getReplyTo()
Get the addresses to which replies should be directed. |
abstract Date |
getSentDate()
Get the date this message was sent. |
abstract String |
getSubject()
Get the subject of this message. |
boolean |
isExpunged()
Checks whether this message is expunged. |
boolean |
isSet(Flags.Flag flag)
Check whether the flag specified in the flag
argument is set in this message. |
boolean |
match(SearchTerm term)
Apply the specified Search criterion to this message. |
abstract Message |
reply(boolean replyToAll)
Get a new Message suitable for a reply to this message. |
abstract void |
saveChanges()
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. |
protected void |
setExpunged(boolean expunged)
Sets the expunged flag for this Message. |
void |
setFlag(Flags.Flag flag,
boolean set)
Set the specified flag on this message to the specified value. |
abstract void |
setFlags(Flags flag,
boolean set)
Set the specified flags on this message to the specified value. |
abstract void |
setFrom()
Set the "From" attribute in this Message. |
abstract void |
setFrom(Address address)
Set the "From" attribute in this Message. |
protected void |
setMessageNumber(int msgnum)
Set the Message number for this Message. |
void |
setRecipient(Message.RecipientType type,
Address address)
Set the recipient address. |
abstract void |
setRecipients(Message.RecipientType type,
Address[] addresses)
Set the recipient addresses. |
void |
setReplyTo(Address[] addresses)
Set the addresses to which replies should be directed. |
abstract void |
setSentDate(Date date)
Set the sent date of this message. |
abstract void |
setSubject(String subject)
Set the subject of this message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.mail.Part |
---|
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 |
Field Detail |
---|
英文文档:
msgnum
protected int msgnum
- The number of this message within its folder, or zero if
the message was not retrieved from a folder.
英文文档:
expunged
protected boolean expunged
- True if this message has been expunged.
英文文档:
folder
protected Folder folder
- The containing folder, if this message is obtained from a folder
英文文档:
session
protected Session session
- The Session object for this Message
Constructor Detail |
---|
protected
Message()
无参数构造方法。
英文文档:
Message
protected Message()
- No-arg version of the constructor.
protected
Message(Folder folder, int msgnum)
带 Folder 和消息编号的构造方法。由 Folder 实现使用。
folder | 包含文件夹 |
msgnum | 此消息在此文件夹中的序列号 |
Message
protected Message(Folder folder, int msgnum)
- Constructor that takes a Folder and a message number.
Used by Folder implementations.
- Parameters:
folder
- containing foldermsgnum
- this message's sequence number within this folder
protected
Message(Session session)
带 Session 的构造方法。用于客户端创建的 Message 对象。
session | Session 对象 |
Message
protected Message(Session session)
- Constructor that takes a Session. Used for client created
Message objects.
- Parameters:
session
- A Session object
Method Detail |
---|
abstract public Address[]
getFrom() throws MessagingException
返回 "From" 属性。"From" 属性包含希望发送此消息的人员的身份信息。
在某些实现中,这可能与实际发送消息的实体不同。
如果此消息中不存在这个属性,则此方法返回 null
。如果此属性存在,但不包含任何地址,则返回一个空数组。
return | Address 对象数组 |
Throws | MessagingException: |
getFrom
public abstract Address[] getFrom() throws MessagingException
- 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. - Returns:
- array of Address objects
- Throws:
MessagingException
abstract public void
setFrom() throws MessagingException
设置此 Message 中的 "From" 属性。此属性的值是从属性 "mail.user" 获取的。如果此属性不存在,则使用系统属性 "user.name"。
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
setFrom
public abstract void setFrom() throws 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.
- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.
abstract public void
setFrom(Address address) throws MessagingException
设置此 Message 中的 "From" 属性。
address | 发送方 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
setFrom
public abstract void setFrom(Address address) throws MessagingException
- Set the "From" attribute in this Message.
- Parameters:
address
- the sender- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.
abstract public void
addFrom(Address[] addresses) throws MessagingException
将这些地址添加到现有 "From" 属性。
addresses | 发送方 |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
Throws | MessagingException: |
addFrom
public abstract void addFrom(Address[] addresses) throws MessagingException
- Add these addresses to the existing "From" attribute
- Parameters:
addresses
- the senders- Throws:
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.MessagingException
abstract public Address[]
getRecipients(Message.RecipientType type) throws MessagingException
获取给定类型的所有接收方地址。
如果此消息中不存在给定类型的接收方,则此方法返回 null
。如果头存在,但不包含任何地址,则返回一个空数组。
type | 接收方类型 |
return | Address 对象数组 |
Throws | MessagingException: |
See also | TO, CC, BCC |
getRecipients
public abstract Address[] getRecipients(Message.RecipientType type) throws 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. - Parameters:
type
- the recipient type- Returns:
- array of Address objects
- Throws:
MessagingException
- See Also:
Message.RecipientType.TO
,Message.RecipientType.CC
,Message.RecipientType.BCC
public Address[]
getAllRecipients() throws MessagingException
获取消息的所有接收方地址。默认实现使用 getRecipients
方法提取 TO、CC 和 BCC 接收方。
如果此消息中不存在接收方头,则此方法返回 null
。如果接收方头存在,但不包含任何地址,则返回一个空数组。
return | Address 对象数组 |
Throws | MessagingException: |
See also | TO, CC, BCC, getRecipients |
getAllRecipients
public Address[] getAllRecipients() throws 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. - Returns:
- array of Address objects
- Throws:
MessagingException
- See Also:
Message.RecipientType.TO
,Message.RecipientType.CC
,Message.RecipientType.BCC
,getRecipients(javax.mail.Message.RecipientType)
abstract public void
setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
设置接收方地址。所有指定类型的地址都由 addresses 参数替代。
type | 接收方类型 |
addresses | 地址 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
setRecipients
public abstract void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
- Set the recipient addresses. All addresses of the specified
type are replaced by the addresses parameter.
- Parameters:
type
- the recipient typeaddresses
- the addresses- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.
public void
setRecipient(Message.RecipientType type, Address address) throws MessagingException
设置接收方地址。所有指定类型的地址都由 address 参数替代。
默认实现使用 setRecipients
方法。
type | 接收方类型 |
address | 地址 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
setRecipient
public void setRecipient(Message.RecipientType type, Address address) throws MessagingException
- Set the recipient address. All addresses of the specified
type are replaced by the address parameter.
The default implementation uses the
setRecipients
method. - Parameters:
type
- the recipient typeaddress
- the address- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing values
abstract public void
addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
将这些接收方地址添加到给定类型的现存地址中。
type | 接收方类型 |
addresses | 地址 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
addRecipients
public abstract void addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
- Add these recipient addresses to the existing ones of the given type.
- Parameters:
type
- the recipient typeaddresses
- the addresses- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.
public void
addRecipient(Message.RecipientType type, Address address) throws MessagingException
将此接收方地址添加到给定类型的现存地址中。
默认实现使用 addRecipients
方法。
type | 接收方类型 |
address | 地址 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
addRecipient
public void addRecipient(Message.RecipientType type, Address address) throws MessagingException
- Add this recipient address to the existing ones of the given type.
The default implementation uses the
addRecipients
method. - Parameters:
type
- the recipient typeaddress
- the address- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing values
public Address[]
getReplyTo() throws MessagingException
获取应该发送回复的地址。这通常是消息的发送方,但一些消息可能将回复发送到其他地址。
默认实现仅调用 getFrom
方法。
如果相应的头不存在,则此方法返回 null
。如果头存在,但不包含任何地址,则返回一个空数组。
return | 应该发送回复的地址 |
Throws | MessagingException: |
See also | getFrom |
getReplyTo
public Address[] getReplyTo() throws 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. - Returns:
- addresses to which replies should be directed
- Throws:
MessagingException
- See Also:
getFrom()
public void
setReplyTo(Address[] addresses) throws MessagingException
设置发送回复的地址。(通常只会指定一个地址。)并非所有消息类型都允许独立于消息发送方指定此地址。
此处提供的默认实现仅抛出 MethodNotSupportedException。
addresses | 应该发送回复的地址 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
Throws | MethodNotSupportedException: 如果底层实现不支持设置此属性 |
setReplyTo
public void setReplyTo(Address[] addresses) throws 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.
- Parameters:
addresses
- addresses to which replies should be directed- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.MethodNotSupportedException
- if the underlying implementation does not support setting this attribute
abstract public String
getSubject() throws MessagingException
获取此消息的主题。
return | 主题 |
Throws | MessagingException: |
getSubject
public abstract String getSubject() throws MessagingException
- Get the subject of this message.
- Returns:
- the subject
- Throws:
MessagingException
abstract public void
setSubject(String subject) throws MessagingException
设置此消息的主题。
subject | 主题 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
setSubject
public abstract void setSubject(String subject) throws MessagingException
- Set the subject of this message.
- Parameters:
subject
- the subject- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.
abstract public java.util.Date
getSentDate() throws MessagingException
获取发送此消息的日期。
return | 发送此消息的日期 |
Throws | MessagingException: |
getSentDate
public abstract Date getSentDate() throws MessagingException
- Get the date this message was sent.
- Returns:
- the date this message was sent
- Throws:
MessagingException
abstract public void
setSentDate(java.util.Date date) throws MessagingException
设置此消息的发送日期。
date | 此消息的发送日期 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
setSentDate
public abstract void setSentDate(Date date) throws MessagingException
- Set the sent date of this message.
- Parameters:
date
- the sent date of this message- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing valuesIllegalStateException
- if this message is obtained from a READ_ONLY folder.
abstract public java.util.Date
getReceivedDate() throws MessagingException
获取收到此消息的日期。
return | 收到此消息的日期 |
Throws | MessagingException: |
getReceivedDate
public abstract Date getReceivedDate() throws MessagingException
- Get the date this message was received.
- Returns:
- the date this message was received
- Throws:
MessagingException
abstract public Flags
getFlags() throws MessagingException
返回包含此消息的标志的 Flags
对象。
修改这个返回的 Flags 对象中的任何标志都不会影响此消息的标志。可使用 setFlags()
完成此操作。
return | 包含此消息标志的 Flags 对象。 |
Throws | MessagingException: |
See also | javax.mail.Flags, setFlags |
getFlags
public abstract Flags getFlags() throws 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. - Returns:
- Flags object containing the flags for this message
- Throws:
MessagingException
- See Also:
Flags
,setFlags(javax.mail.Flags, boolean)
public boolean
isSet(Flags.Flag flag) throws MessagingException
检查此消息中是否设置了 flag
参数中指定的标志。
默认实现使用 getFlags
。
flag | 标志 |
return | 此消息指定标志的值 |
Throws | MessagingException: |
See also | javax.mail.Flags.Flag, ANSWERED, DELETED, DRAFT, FLAGGED, RECENT, SEEN |
isSet
public boolean isSet(Flags.Flag flag) throws MessagingException
- Check whether the flag specified in the
flag
argument is set in this message.The default implementation uses
getFlags
. - Parameters:
flag
- the flag- Returns:
- value of the specified flag for this message
- Throws:
MessagingException
- See Also:
Flags.Flag
,Flags.Flag.ANSWERED
,Flags.Flag.DELETED
,Flags.Flag.DRAFT
,Flags.Flag.FLAGGED
,Flags.Flag.RECENT
,Flags.Flag.SEEN
abstract public void
setFlags(Flags flag, boolean set) throws MessagingException
将此消息上的指定标志设置为指定值。注意,此消息中未在给定 Flags
对象中指定的任何标志都不受影响。
这将导致向此 Message 包含文件夹上注册的任何 MessageChangedListener 传送 MessageChangedEvent
。
flag | 包含要设置的标志的 Flag 对象 |
set | 要设置的值 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值。 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
See also | javax.mail.event.MessageChangedEvent |
setFlags
public abstract void setFlags(Flags flag, boolean set) throws 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. - Parameters:
flag
- Flags object containing the flags to be setset
- the value to be set- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing values.IllegalStateException
- if this message is obtained from a READ_ONLY folder.- See Also:
MessageChangedEvent
public void
setFlag(Flags.Flag flag, boolean set) throws MessagingException
将此消息上的指定标志设置为指定值。
这将导致向此 Message 包含文件夹上注册的任何 MessageChangedListener 传送 MessageChangedEvent
。
默认实现使用 setFlags
方法。
flag | 包含要设置的标志的 Flags.Flag 对象 |
set | 要设置的值 |
Throws | MessagingException: |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值。 |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
See also | javax.mail.event.MessageChangedEvent |
setFlag
public void setFlag(Flags.Flag flag, boolean set) throws 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. - Parameters:
flag
- Flags.Flag object containing the flag to be setset
- the value to be set- Throws:
MessagingException
IllegalWriteException
- if the underlying implementation does not support modification of existing values.IllegalStateException
- if this message is obtained from a READ_ONLY folder.- See Also:
MessageChangedEvent
public int
getMessageNumber()
获取此 Message 的 Message 编号。Message 对象的消息编号是其 Folder 中此 Message 的相对位置。注意,如果会话期间删除(擦除)了 Folder 中的其他消息,则特定 Message 的消息编号可能发生更改。
有效的消息编号从 1 开始。不属于任何文件夹的消息(比如新撰写的消息或派生的消息)使用 0 作为其消息编号。
return | 消息编号 |
getMessageNumber
public int getMessageNumber()
- Get the Message number for this Message.
A Message object's message number is the relative
position of this Message in its Folder. Note that the message
number for a particular Message can change during a session
if other messages in the Folder 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.
- Returns:
- the message number
protected void
setMessageNumber(int msgnum)
设置此 Message 的 Message 编号。此方法仅供实现类调用。
英文文档:
setMessageNumber
protected void setMessageNumber(int msgnum)
- Set the Message number for this Message. This method is
invoked only by the implementation classes.
public Folder
getFolder()
获取可从中获得此消息的文件夹。如果此消息是一条新消息或者嵌套消息,则此方法返回 null。
return | 包含文件夹 |
getFolder
public Folder getFolder()
- Get the folder from which this message was obtained. If
this is a new message or nested message, this method returns
null.
- Returns:
- the containing folder
public boolean
isExpunged()
检查是否擦除了此消息。除 getMessageNumber()
以外,所有其他方法对已擦除的 Message 对象都是无效的。
由于对包含 Folder 显式调用 expunge()
而被擦除的 Message 将立即从该 Folder 中移除。由于另一个原因被外部擦除的 Message 将标记为 "expunged",并在调用 isExpunged() 方法时返回 true,但直到对 Folder 显式调用 expunge()
时才将其从该 Folder 中移除。
有关擦除处理的更多详细信息,请参见 expunge()
的描述。
See also | expunge |
isExpunged
public boolean isExpunged()
- 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 Folder are removed from the Folder 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 Folder until an explicitexpunge()
is done on the Folder.See the description of
expunge()
for more details on expunge handling. - See Also:
Folder.expunge()
protected void
setExpunged(boolean expunged)
设置此 Message 的 expunged 标志。此方法仅供实现类使用。
expunged | expunged 标志 |
setExpunged
protected void setExpunged(boolean expunged)
- Sets the expunged flag for this Message. This method is to
be used only by the implementation classes.
- Parameters:
expunged
- the expunged flag
abstract public Message
reply(boolean replyToAll) throws MessagingException
获取适用于回复此消息的新 Message。新的 Message 将恰当设置其属性和头。注意,这个新消息对象为空,即它没有 "content"。这些必须由客户端恰当地填充。
如果设置了 replyToAll
,则新的 Message 将发送给此消息的所有接收方。否则,回复将只发送给此消息的发送方(使用 getReplyTo
方法的值)。
"Subject" 字段使用原主题加上前缀 "Re:" 填写(除非它已经以 "Re:" 开头)。
回复消息将使用与此消息相同的会话。
replyToAll | 回复应该发送给此消息的所有接收方 |
return | 回复 Message |
Throws | MessagingException: |
reply
public abstract Message reply(boolean replyToAll) throws 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 thegetReplyTo
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.
- Parameters:
replyToAll
- reply should be sent to all recipients of this message- Returns:
- the reply Message
- Throws:
MessagingException
abstract public void
saveChanges() throws MessagingException
如果消息包含在某个文件夹中,那么当该包含文件夹关闭时,对此消息进行的所有更改将保存到消息存储库中。(一些实现可能会立刻保存这些更改。)更新所有头字段,使它们与已更改的消息内容一致。如果消息的头或内容的任何部分发生更改,则必须调用 saveChanges 确保这些更改是永久性的。如果没有调用 saveChanges,那么这些修改也许被保存,也许不被保存,具体取决于消息存储库和 Folder 实现。
不应该修改从设置为 READ_ONLY 的文件夹获取的消息,也不应对这些消息调用 saveChanges。
Throws | MessagingException: |
Throws | IllegalStateException: 如果此消息是从 READ_ONLY 文件夹获取的。 |
Throws | IllegalWriteException: 如果底层实现不支持修改现有值。 |
saveChanges
public abstract void saveChanges() throws 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.
- Throws:
MessagingException
IllegalStateException
- if this message is obtained from a READ_ONLY folder.IllegalWriteException
- if the underlying implementation does not support modification of existing values.
public boolean
match(SearchTerm term) throws MessagingException
将指定 Search 标准应用于此消息。
term | Search 标准 |
return | 如果 Message 与此搜索标准匹配,则返回 true;否则返回 false。 |
Throws | MessagingException: |
See also | javax.mail.search.SearchTerm |
match
public boolean match(SearchTerm term) throws MessagingException
- Apply the specified Search criterion to this message.
- Parameters:
term
- the Search criterion- Returns:
- true if the Message matches this search criterion, false otherwise.
- Throws:
MessagingException
- See Also:
SearchTerm
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!