public class IMAPMessage
extends MimeMessage
An IMAPMessage object starts out as a light-weight object. It gets filled-in incrementally when a request is made for some item. Or when a prefetch is done using the FetchProfile.
An IMAPMessage has a messageNumber and a sequenceNumber. The messageNumber is its index into its containing folder's messageCache. The sequenceNumber is its IMAP sequence-number.
| Modifier and Type | Field and Description |
|---|---|
protected BODYSTRUCTURE |
bs |
protected ENVELOPE |
envelope |
protected java.lang.String |
sectionId |
| Modifier | Constructor and Description |
|---|---|
protected |
IMAPMessage(IMAPFolder folder,
int msgnum)
Constructor.
|
protected |
IMAPMessage(Session session)
Constructor, for use by IMAPNestedMessage.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFrom(Address[] addresses) |
void |
addHeader(java.lang.String name,
java.lang.String value) |
void |
addHeaderLine(java.lang.String line) |
void |
addRecipients(Message.RecipientType type,
Address[] addresses) |
protected void |
checkExpunged() |
protected void |
forceCheckExpunged()
Do a NOOP to force any untagged EXPUNGE responses
and then check if this message is expunged.
|
java.util.Enumeration |
getAllHeaderLines()
Get all header-lines.
|
java.util.Enumeration |
getAllHeaders()
Get all headers.
|
java.lang.String |
getContentID()
Get the Content-ID.
|
java.lang.String[] |
getContentLanguage()
Get the content language.
|
java.lang.String |
getContentMD5()
Get the Content-MD5.
|
protected java.io.InputStream |
getContentStream()
Get all the bytes for this message.
|
java.lang.String |
getContentType()
Get the Content-Type.
|
javax.activation.DataHandler |
getDataHandler()
Get the DataHandler object for this message.
|
java.lang.String |
getDescription()
Get the decoded Content-Description.
|
java.lang.String |
getDisposition()
Get the Content-Disposition.
|
java.lang.String |
getEncoding()
Get the Content-Transfer-Encoding.
|
protected int |
getFetchBlockSize() |
java.lang.String |
getFileName()
Get the "filename" Disposition parameter.
|
Flags |
getFlags()
Get the Flags for this message.
|
Address[] |
getFrom()
Get the "From" attribute.
|
java.lang.String[] |
getHeader(java.lang.String name)
Get the named header.
|
java.lang.String |
getHeader(java.lang.String name,
java.lang.String delimiter)
Get the named header.
|
java.lang.String |
getInReplyTo()
Get the In-Reply-To header.
|
int |
getLineCount()
Get the total number of lines.
|
java.util.Enumeration |
getMatchingHeaderLines(java.lang.String[] names)
Get all matching header-lines.
|
java.util.Enumeration |
getMatchingHeaders(java.lang.String[] names)
Get matching headers.
|
protected java.lang.Object |
getMessageCacheLock()
Get the messageCacheLock, associated with this Message's
Folder.
|
java.lang.String |
getMessageID()
Get the Message-ID.
|
java.util.Enumeration |
getNonMatchingHeaderLines(java.lang.String[] names)
Get all non-matching headerlines.
|
java.util.Enumeration |
getNonMatchingHeaders(java.lang.String[] names)
Get non-matching headers.
|
boolean |
getPeek()
Get whether or not to use the PEEK variant of FETCH when
fetching message content.
|
protected IMAPProtocol |
getProtocol()
Get this message's folder's protocol connection.
|
java.util.Date |
getReceivedDate()
Get the recieved date (INTERNALDATE)
|
Address[] |
getRecipients(Message.RecipientType type)
Get the desired Recipient type.
|
Address[] |
getReplyTo()
Get the ReplyTo addresses.
|
Address |
getSender()
Get the "Sender" attribute.
|
java.util.Date |
getSentDate()
Get the SentDate.
|
protected int |
getSequenceNumber()
Get this message's IMAP sequence number.
|
int |
getSize()
Get the message size.
|
java.lang.String |
getSubject()
Get the decoded subject.
|
protected long |
getUID() |
void |
invalidateHeaders()
Invalidate cached header and envelope information for this
message.
|
protected boolean |
isREV1() |
boolean |
isSet(Flags.Flag flag)
Test if the given Flags are set in this message.
|
void |
removeHeader(java.lang.String name) |
void |
setContentID(java.lang.String cid) |
void |
setContentLanguage(java.lang.String[] languages) |
void |
setContentMD5(java.lang.String md5) |
void |
setDataHandler(javax.activation.DataHandler content) |
void |
setDescription(java.lang.String description,
java.lang.String charset) |
void |
setDisposition(java.lang.String disposition) |
protected void |
setExpunged(boolean set) |
void |
setFileName(java.lang.String filename) |
void |
setFlags(Flags flag,
boolean set)
Set/Unset the given flags in this message.
|
void |
setFrom(Address address) |
void |
setHeader(java.lang.String name,
java.lang.String value) |
protected void |
setMessageNumber(int msgnum)
Wrapper around the protected method Message.setMessageNumber() to
make that method accessible to IMAPFolder.
|
void |
setPeek(boolean peek)
Set whether or not to use the PEEK variant of FETCH when
fetching message content.
|
void |
setRecipients(Message.RecipientType type,
Address[] addresses) |
void |
setReplyTo(Address[] addresses) |
void |
setSender(Address address) |
void |
setSentDate(java.util.Date d) |
void |
setSubject(java.lang.String subject,
java.lang.String charset) |
protected void |
setUID(long uid) |
void |
writeTo(java.io.OutputStream os)
Write out the bytes into the given outputstream.
|
protected BODYSTRUCTURE bs
protected ENVELOPE envelope
protected java.lang.String sectionId
protected IMAPMessage(IMAPFolder folder, int msgnum)
protected IMAPMessage(Session session)
protected IMAPProtocol getProtocol() throws ProtocolException, FolderClosedException
ProtocolExceptionFolderClosedExceptionprotected boolean isREV1()
throws FolderClosedException
FolderClosedExceptionprotected java.lang.Object getMessageCacheLock()
protected int getSequenceNumber()
protected void setMessageNumber(int msgnum)
protected long getUID()
protected void setUID(long uid)
protected void setExpunged(boolean set)
protected void checkExpunged()
throws MessageRemovedException
MessageRemovedExceptionprotected void forceCheckExpunged()
throws MessageRemovedException,
FolderClosedException
MessageRemovedExceptionFolderClosedExceptionprotected int getFetchBlockSize()
public Address[] getFrom()
throws MessagingException
MessagingExceptionpublic void setFrom(Address address)
throws MessagingException
MessagingExceptionpublic void addFrom(Address[] addresses)
throws MessagingException
MessagingExceptionpublic Address getSender()
throws MessagingException
MessagingExceptionpublic void setSender(Address address)
throws MessagingException
MessagingExceptionpublic Address[] getRecipients(Message.RecipientType type)
throws MessagingException
MessagingExceptionpublic void setRecipients(Message.RecipientType type,
Address[] addresses)
throws MessagingException
MessagingExceptionpublic void addRecipients(Message.RecipientType type,
Address[] addresses)
throws MessagingException
MessagingExceptionpublic Address[] getReplyTo()
throws MessagingException
MessagingExceptionpublic void setReplyTo(Address[] addresses)
throws MessagingException
MessagingExceptionpublic java.lang.String getSubject()
throws MessagingException
MessagingExceptionpublic void setSubject(java.lang.String subject,
java.lang.String charset)
throws MessagingException
MessagingExceptionpublic java.util.Date getSentDate()
throws MessagingException
MessagingExceptionpublic void setSentDate(java.util.Date d)
throws MessagingException
MessagingExceptionpublic java.util.Date getReceivedDate()
throws MessagingException
MessagingExceptionpublic int getSize()
throws MessagingException
Note that this returns RFC822.SIZE. That is, it's the size of the whole message, header and body included.
MessagingExceptionpublic int getLineCount()
throws MessagingException
Returns the "body_fld_lines" field from the BODYSTRUCTURE. Note that this field is available only for text/plain and message/rfc822 types
MessagingExceptionpublic java.lang.String[] getContentLanguage()
throws MessagingException
MessagingExceptionpublic void setContentLanguage(java.lang.String[] languages)
throws MessagingException
MessagingExceptionpublic java.lang.String getInReplyTo()
throws MessagingException
MessagingExceptionpublic java.lang.String getContentType()
throws MessagingException
MessagingExceptionpublic java.lang.String getDisposition()
throws MessagingException
MessagingExceptionpublic void setDisposition(java.lang.String disposition)
throws MessagingException
MessagingExceptionpublic java.lang.String getEncoding()
throws MessagingException
MessagingExceptionpublic java.lang.String getContentID()
throws MessagingException
MessagingExceptionpublic void setContentID(java.lang.String cid)
throws MessagingException
MessagingExceptionpublic java.lang.String getContentMD5()
throws MessagingException
MessagingExceptionpublic void setContentMD5(java.lang.String md5)
throws MessagingException
MessagingExceptionpublic java.lang.String getDescription()
throws MessagingException
MessagingExceptionpublic void setDescription(java.lang.String description,
java.lang.String charset)
throws MessagingException
MessagingExceptionpublic java.lang.String getMessageID()
throws MessagingException
MessagingExceptionpublic java.lang.String getFileName()
throws MessagingException
MessagingExceptionpublic void setFileName(java.lang.String filename)
throws MessagingException
MessagingExceptionprotected java.io.InputStream getContentStream()
throws MessagingException
MessagingExceptionjavax.mail.internet.MimeMessage#getContentStreampublic javax.activation.DataHandler getDataHandler()
throws MessagingException
MessagingExceptionpublic void setDataHandler(javax.activation.DataHandler content)
throws MessagingException
MessagingExceptionpublic void writeTo(java.io.OutputStream os)
throws java.io.IOException,
MessagingException
java.io.IOExceptionMessagingExceptionpublic java.lang.String[] getHeader(java.lang.String name)
throws MessagingException
MessagingExceptionpublic java.lang.String getHeader(java.lang.String name,
java.lang.String delimiter)
throws MessagingException
MessagingExceptionpublic void setHeader(java.lang.String name,
java.lang.String value)
throws MessagingException
MessagingExceptionpublic void addHeader(java.lang.String name,
java.lang.String value)
throws MessagingException
MessagingExceptionpublic void removeHeader(java.lang.String name)
throws MessagingException
MessagingExceptionpublic java.util.Enumeration getAllHeaders()
throws MessagingException
MessagingExceptionpublic java.util.Enumeration getMatchingHeaders(java.lang.String[] names)
throws MessagingException
MessagingExceptionpublic java.util.Enumeration getNonMatchingHeaders(java.lang.String[] names)
throws MessagingException
MessagingExceptionpublic void addHeaderLine(java.lang.String line)
throws MessagingException
MessagingExceptionpublic java.util.Enumeration getAllHeaderLines()
throws MessagingException
MessagingExceptionpublic java.util.Enumeration getMatchingHeaderLines(java.lang.String[] names)
throws MessagingException
MessagingExceptionpublic java.util.Enumeration getNonMatchingHeaderLines(java.lang.String[] names)
throws MessagingException
MessagingExceptionpublic Flags getFlags()
throws MessagingException
MessagingExceptionpublic boolean isSet(Flags.Flag flag)
throws MessagingException
MessagingExceptionpublic void setFlags(Flags flag,
boolean set)
throws MessagingException
MessagingExceptionpublic void setPeek(boolean peek)
public boolean getPeek()
public void invalidateHeaders()