com.sun.mail.imap
Class IMAPMessage

java.lang.Object
  extended by javax.mail.Message
      extended by javax.mail.internet.MimeMessage
          extended by com.sun.mail.imap.IMAPMessage
All Implemented Interfaces:
javax.mail.internet.MimePart, javax.mail.Part
Direct Known Subclasses:
IMAPNestedMessage

public class IMAPMessage
extends javax.mail.internet.MimeMessage

This class implements an IMAPMessage object.

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.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.mail.internet.MimeMessage
javax.mail.internet.MimeMessage.RecipientType
 
Field Summary
protected  BODYSTRUCTURE bs
           
protected  ENVELOPE envelope
           
protected  java.lang.String sectionId
           
 
Fields inherited from class javax.mail.internet.MimeMessage
content, contentStream, dh, flags, headers, modified, saved
 
Fields inherited from class javax.mail.Message
expunged, folder, msgnum, session
 
Fields inherited from interface javax.mail.Part
ATTACHMENT, INLINE
 
Constructor Summary
protected IMAPMessage(IMAPFolder folder, int msgnum, int seqnum)
          Constructor.
protected IMAPMessage(javax.mail.Session session)
          Constructor, for use by IMAPNestedMessage.
 
Method Summary
 void addFrom(javax.mail.Address[] addresses)
          Add the specified addresses to the existing "From" field.
 void addHeader(java.lang.String name, java.lang.String value)
          Add this value to the existing values for this header_name.
 void addHeaderLine(java.lang.String line)
          Add a raw RFC 822 header-line.
 void addRecipients(javax.mail.Message.RecipientType type, javax.mail.Address[] addresses)
          Add the given addresses to the specified recipient type.
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.
 javax.mail.Flags getFlags()
          Get the Flags for this message.
 javax.mail.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)
 javax.mail.Address[] getRecipients(javax.mail.Message.RecipientType type)
          Get the desired Recipient type.
 javax.mail.Address[] getReplyTo()
          Get the ReplyTo addresses.
 javax.mail.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(javax.mail.Flags.Flag flag)
          Test if the given Flags are set in this message.
 void removeHeader(java.lang.String name)
          Remove all headers with this name.
 void setContentID(java.lang.String cid)
          Set the "Content-ID" header field of this Message.
 void setContentLanguage(java.lang.String[] languages)
          Set the "Content-Language" header of this MimePart.
 void setContentMD5(java.lang.String md5)
          Set the "Content-MD5" header field of this Message.
 void setDataHandler(javax.activation.DataHandler content)
          This method provides the mechanism to set this part's content.
 void setDescription(java.lang.String description, java.lang.String charset)
          Set the "Content-Description" header field for this Message.
 void setDisposition(java.lang.String disposition)
          Set the "Content-Disposition" header field of this Message.
protected  void setExpunged(boolean set)
          Sets the expunged flag for this Message.
 void setFileName(java.lang.String filename)
          Set the filename associated with this part, if possible.
 void setFlags(javax.mail.Flags flag, boolean set)
          Set/Unset the given flags in this message.
 void setFrom(javax.mail.Address address)
          Set the RFC 822 "From" header field.
 void setHeader(java.lang.String name, java.lang.String value)
          Set the value for this header_name.
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(javax.mail.Message.RecipientType type, javax.mail.Address[] addresses)
          Set the specified recipient type to the given addresses.
 void setReplyTo(javax.mail.Address[] addresses)
          Set the RFC 822 "Reply-To" header field.
 void setSender(javax.mail.Address address)
          Set the RFC 822 "Sender" header field.
 void setSentDate(java.util.Date d)
          Set the RFC 822 "Date" header field.
protected  void setSequenceNumber(int seqnum)
          Set this message's IMAP sequence number.
 void setSubject(java.lang.String subject, java.lang.String charset)
          Set the "Subject" header field.
protected  void setUID(long uid)
           
 void writeTo(java.io.OutputStream os)
          Write out the bytes into the given outputstream.
 
Methods inherited from class javax.mail.internet.MimeMessage
addRecipients, createInternetHeaders, createMimeMessage, getAllRecipients, getContent, getInputStream, getRawInputStream, isMimeType, parse, reply, saveChanges, setContent, setContent, setDescription, setFrom, setRecipients, setSubject, setText, setText, setText, updateHeaders, updateMessageID, writeTo
 
Methods inherited from class javax.mail.Message
addRecipient, getFolder, getMessageNumber, isExpunged, match, setFlag, setRecipient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bs

protected BODYSTRUCTURE bs

envelope

protected ENVELOPE envelope

sectionId

protected java.lang.String sectionId
Constructor Detail

IMAPMessage

protected IMAPMessage(IMAPFolder folder,
                      int msgnum,
                      int seqnum)
Constructor.


IMAPMessage

protected IMAPMessage(javax.mail.Session session)
Constructor, for use by IMAPNestedMessage.

Method Detail

getProtocol

protected IMAPProtocol getProtocol()
                            throws ProtocolException,
                                   javax.mail.FolderClosedException
Get this message's folder's protocol connection. Throws FolderClosedException, if the protocol connection is not available. ASSERT: Must hold the messageCacheLock.

Throws:
ProtocolException
javax.mail.FolderClosedException

isREV1

protected boolean isREV1()
                  throws javax.mail.FolderClosedException
Throws:
javax.mail.FolderClosedException

getMessageCacheLock

protected java.lang.Object getMessageCacheLock()
Get the messageCacheLock, associated with this Message's Folder.


getSequenceNumber

protected int getSequenceNumber()
Get this message's IMAP sequence number. ASSERT: This method must be called only when holding the messageCacheLock.


setSequenceNumber

protected void setSequenceNumber(int seqnum)
Set this message's IMAP sequence number. ASSERT: This method must be called only when holding the messageCacheLock.


setMessageNumber

protected void setMessageNumber(int msgnum)
Wrapper around the protected method Message.setMessageNumber() to make that method accessible to IMAPFolder.

Overrides:
setMessageNumber in class javax.mail.Message

getUID

protected long getUID()

setUID

protected void setUID(long uid)

setExpunged

protected void setExpunged(boolean set)
Description copied from class: javax.mail.Message
Sets the expunged flag for this Message. This method is to be used only by the implementation classes.

Overrides:
setExpunged in class javax.mail.Message
Parameters:
set - the expunged flag

checkExpunged

protected void checkExpunged()
                      throws javax.mail.MessageRemovedException
Throws:
javax.mail.MessageRemovedException

forceCheckExpunged

protected void forceCheckExpunged()
                           throws javax.mail.MessageRemovedException,
                                  javax.mail.FolderClosedException
Do a NOOP to force any untagged EXPUNGE responses and then check if this message is expunged.

Throws:
javax.mail.MessageRemovedException
javax.mail.FolderClosedException

getFetchBlockSize

protected int getFetchBlockSize()

getFrom

public javax.mail.Address[] getFrom()
                             throws javax.mail.MessagingException
Get the "From" attribute.

Overrides:
getFrom in class javax.mail.internet.MimeMessage
Returns:
Address object
Throws:
javax.mail.MessagingException
See Also:
MimeMessage.headers

setFrom

public void setFrom(javax.mail.Address address)
             throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the RFC 822 "From" header field. Any existing values are replaced with the given address. If address is null, this header is removed.

Overrides:
setFrom in class javax.mail.internet.MimeMessage
Parameters:
address - the sender of this message
Throws:
javax.mail.MessagingException

addFrom

public void addFrom(javax.mail.Address[] addresses)
             throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Add the specified addresses to the existing "From" field. If the "From" field does not already exist, it is created.

Overrides:
addFrom in class javax.mail.internet.MimeMessage
Parameters:
addresses - the senders of this message
Throws:
javax.mail.MessagingException

getSender

public javax.mail.Address getSender()
                             throws javax.mail.MessagingException
Get the "Sender" attribute.

Overrides:
getSender in class javax.mail.internet.MimeMessage
Returns:
Address object
Throws:
javax.mail.MessagingException
See Also:
MimeMessage.headers

setSender

public void setSender(javax.mail.Address address)
               throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the RFC 822 "Sender" header field. Any existing values are replaced with the given address. If address is null, this header is removed.

Overrides:
setSender in class javax.mail.internet.MimeMessage
Parameters:
address - the sender of this message
Throws:
javax.mail.IllegalWriteException - if the underlying implementation does not support modification of existing values
javax.mail.MessagingException

getRecipients

public javax.mail.Address[] getRecipients(javax.mail.Message.RecipientType type)
                                   throws javax.mail.MessagingException
Get the desired Recipient type.

Overrides:
getRecipients in class javax.mail.internet.MimeMessage
Parameters:
type - Type of recepient
Returns:
array of Address objects
Throws:
javax.mail.MessagingException - if header could not be retrieved
javax.mail.internet.AddressException - if the header is misformatted
See Also:
MimeMessage.headers, Message.RecipientType.TO, Message.RecipientType.CC, Message.RecipientType.BCC, MimeMessage.RecipientType.NEWSGROUPS

setRecipients

public void setRecipients(javax.mail.Message.RecipientType type,
                          javax.mail.Address[] addresses)
                   throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the specified recipient type to the given addresses. If the address parameter is null, the corresponding recipient field is removed.

Overrides:
setRecipients in class javax.mail.internet.MimeMessage
Parameters:
type - Recipient type
addresses - Addresses
Throws:
javax.mail.MessagingException
See Also:
MimeMessage.getRecipients(javax.mail.Message.RecipientType)

addRecipients

public void addRecipients(javax.mail.Message.RecipientType type,
                          javax.mail.Address[] addresses)
                   throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Add the given addresses to the specified recipient type.

Overrides:
addRecipients in class javax.mail.internet.MimeMessage
Parameters:
type - Recipient type
addresses - Addresses
Throws:
javax.mail.MessagingException

getReplyTo

public javax.mail.Address[] getReplyTo()
                                throws javax.mail.MessagingException
Get the ReplyTo addresses.

Overrides:
getReplyTo in class javax.mail.internet.MimeMessage
Returns:
addresses to which replies should be directed
Throws:
javax.mail.MessagingException
See Also:
MimeMessage.headers

setReplyTo

public void setReplyTo(javax.mail.Address[] addresses)
                throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the RFC 822 "Reply-To" header field. If the address parameter is null, this header is removed.

Overrides:
setReplyTo in class javax.mail.internet.MimeMessage
Parameters:
addresses - addresses to which replies should be directed
Throws:
javax.mail.MessagingException

getSubject

public java.lang.String getSubject()
                            throws javax.mail.MessagingException
Get the decoded subject.

Overrides:
getSubject in class javax.mail.internet.MimeMessage
Returns:
Subject
Throws:
javax.mail.MessagingException
See Also:
MimeMessage.headers

setSubject

public void setSubject(java.lang.String subject,
                       java.lang.String charset)
                throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the "Subject" header field. If the subject contains non US-ASCII characters, it will be encoded using the specified charset. If the subject contains only US-ASCII characters, no encoding is done and it is used as-is. If the subject is null, the existing "Subject" header field is removed.

The application must ensure that the subject does not contain any line breaks.

Note that if the charset encoding process fails, a MessagingException is thrown, and an UnsupportedEncodingException is included in the chain of nested exceptions within the MessagingException.

Overrides:
setSubject in class javax.mail.internet.MimeMessage
Parameters:
subject - The subject
charset - The charset
Throws:
javax.mail.IllegalWriteException - if the underlying implementation does not support modification of existing values
javax.mail.MessagingException

getSentDate

public java.util.Date getSentDate()
                           throws javax.mail.MessagingException
Get the SentDate.

Overrides:
getSentDate in class javax.mail.internet.MimeMessage
Returns:
The sent Date
Throws:
javax.mail.MessagingException

setSentDate

public void setSentDate(java.util.Date d)
                 throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the RFC 822 "Date" header field. This is the date on which the creator of the message indicates that the message is complete and ready for delivery. If the date parameter is null, the existing "Date" field is removed.

Overrides:
setSentDate in class javax.mail.internet.MimeMessage
Parameters:
d - the sent date of this message
Throws:
javax.mail.MessagingException

getReceivedDate

public java.util.Date getReceivedDate()
                               throws javax.mail.MessagingException
Get the recieved date (INTERNALDATE)

Overrides:
getReceivedDate in class javax.mail.internet.MimeMessage
Returns:
the date this message was received
Throws:
javax.mail.MessagingException

getSize

public int getSize()
            throws javax.mail.MessagingException
Get the message size.

Note that this returns RFC822.SIZE. That is, it's the size of the whole message, header and body included.

Specified by:
getSize in interface javax.mail.Part
Overrides:
getSize in class javax.mail.internet.MimeMessage
Returns:
size of content in bytes
Throws:
javax.mail.MessagingException

getLineCount

public int getLineCount()
                 throws javax.mail.MessagingException
Get the total number of lines.

Returns the "body_fld_lines" field from the BODYSTRUCTURE. Note that this field is available only for text/plain and message/rfc822 types

Specified by:
getLineCount in interface javax.mail.Part
Overrides:
getLineCount in class javax.mail.internet.MimeMessage
Returns:
number of lines in the content.
Throws:
javax.mail.MessagingException

getContentLanguage

public java.lang.String[] getContentLanguage()
                                      throws javax.mail.MessagingException
Get the content language.

Specified by:
getContentLanguage in interface javax.mail.internet.MimePart
Overrides:
getContentLanguage in class javax.mail.internet.MimeMessage
Returns:
value of content-language header.
Throws:
javax.mail.MessagingException

setContentLanguage

public void setContentLanguage(java.lang.String[] languages)
                        throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the "Content-Language" header of this MimePart. The Content-Language header is defined by RFC 1766.

Specified by:
setContentLanguage in interface javax.mail.internet.MimePart
Overrides:
setContentLanguage in class javax.mail.internet.MimeMessage
Parameters:
languages - array of language tags
Throws:
javax.mail.IllegalWriteException - if the underlying implementation does not support modification
javax.mail.MessagingException

getInReplyTo

public java.lang.String getInReplyTo()
                              throws javax.mail.MessagingException
Get the In-Reply-To header.

Throws:
javax.mail.MessagingException
Since:
JavaMail 1.3.3

getContentType

public java.lang.String getContentType()
                                throws javax.mail.MessagingException
Get the Content-Type. Generate this header from the BODYSTRUCTURE. Append parameters as well.

Specified by:
getContentType in interface javax.mail.Part
Overrides:
getContentType in class javax.mail.internet.MimeMessage
Returns:
The ContentType of this part
Throws:
javax.mail.MessagingException
See Also:
DataHandler

getDisposition

public java.lang.String getDisposition()
                                throws javax.mail.MessagingException
Get the Content-Disposition.

Specified by:
getDisposition in interface javax.mail.Part
Overrides:
getDisposition in class javax.mail.internet.MimeMessage
Returns:
disposition of this part, or null if unknown
Throws:
javax.mail.MessagingException
See Also:
Part.ATTACHMENT, Part.INLINE, Part.getFileName()

setDisposition

public void setDisposition(java.lang.String disposition)
                    throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the "Content-Disposition" header field of this Message. If disposition is null, any existing "Content-Disposition" header field is removed.

Specified by:
setDisposition in interface javax.mail.Part
Overrides:
setDisposition in class javax.mail.internet.MimeMessage
Parameters:
disposition - disposition of this part
Throws:
javax.mail.MessagingException
See Also:
Part.ATTACHMENT, Part.INLINE, Part.setFileName(java.lang.String)

getEncoding

public java.lang.String getEncoding()
                             throws javax.mail.MessagingException
Get the Content-Transfer-Encoding.

Specified by:
getEncoding in interface javax.mail.internet.MimePart
Overrides:
getEncoding in class javax.mail.internet.MimeMessage
Returns:
content-transfer-encoding
Throws:
javax.mail.MessagingException

getContentID

public java.lang.String getContentID()
                              throws javax.mail.MessagingException
Get the Content-ID.

Specified by:
getContentID in interface javax.mail.internet.MimePart
Overrides:
getContentID in class javax.mail.internet.MimeMessage
Returns:
content-ID
Throws:
javax.mail.MessagingException

setContentID

public void setContentID(java.lang.String cid)
                  throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the "Content-ID" header field of this Message. If the cid parameter is null, any existing "Content-ID" is removed.

Overrides:
setContentID in class javax.mail.internet.MimeMessage
Throws:
javax.mail.IllegalWriteException - if the underlying implementation does not support modification
javax.mail.MessagingException

getContentMD5

public java.lang.String getContentMD5()
                               throws javax.mail.MessagingException
Get the Content-MD5.

Specified by:
getContentMD5 in interface javax.mail.internet.MimePart
Overrides:
getContentMD5 in class javax.mail.internet.MimeMessage
Returns:
content-MD5
Throws:
javax.mail.MessagingException

setContentMD5

public void setContentMD5(java.lang.String md5)
                   throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the "Content-MD5" header field of this Message.

Specified by:
setContentMD5 in interface javax.mail.internet.MimePart
Overrides:
setContentMD5 in class javax.mail.internet.MimeMessage
Parameters:
md5 - the MD5 value
Throws:
javax.mail.IllegalWriteException - if the underlying implementation does not support modification
javax.mail.MessagingException

getDescription

public java.lang.String getDescription()
                                throws javax.mail.MessagingException
Get the decoded Content-Description.

Specified by:
getDescription in interface javax.mail.Part
Overrides:
getDescription in class javax.mail.internet.MimeMessage
Returns:
content-description
Throws:
javax.mail.MessagingException

setDescription

public void setDescription(java.lang.String description,
                           java.lang.String charset)
                    throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the "Content-Description" header field for this Message. If the description parameter is null, then any existing "Content-Description" fields are removed.

If the description contains non US-ASCII characters, it will be encoded using the specified charset. If the description contains only US-ASCII characters, no encoding is done and it is used as-is.

Note that if the charset encoding process fails, a MessagingException is thrown, and an UnsupportedEncodingException is included in the chain of nested exceptions within the MessagingException.

Overrides:
setDescription in class javax.mail.internet.MimeMessage
Parameters:
description - Description
charset - Charset for encoding
Throws:
javax.mail.IllegalWriteException - if the underlying implementation does not support modification
javax.mail.MessagingException

getMessageID

public java.lang.String getMessageID()
                              throws javax.mail.MessagingException
Get the Message-ID.

Overrides:
getMessageID in class javax.mail.internet.MimeMessage
Returns:
Message-ID
Throws:
javax.mail.MessagingException - if the retrieval of this field causes any exception.
See Also:
MessageIDTerm

getFileName

public java.lang.String getFileName()
                             throws javax.mail.MessagingException
Get the "filename" Disposition parameter. (Only available in IMAP4rev1). If thats not available, get the "name" ContentType parameter.

Specified by:
getFileName in interface javax.mail.Part
Overrides:
getFileName in class javax.mail.internet.MimeMessage
Returns:
filename
Throws:
javax.mail.MessagingException

setFileName

public void setFileName(java.lang.String filename)
                 throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the filename associated with this part, if possible.

Sets the "filename" parameter of the "Content-Disposition" header field of this message.

If the mail.mime.encodefilename System property is set to true, the MimeUtility.encodeText method will be used to encode the filename. While such encoding is not supported by the MIME spec, many mailers use this technique to support non-ASCII characters in filenames. The default value of this property is false.

Specified by:
setFileName in interface javax.mail.Part
Overrides:
setFileName in class javax.mail.internet.MimeMessage
Parameters:
filename - Filename to associate with this part
Throws:
javax.mail.MessagingException

getContentStream

protected java.io.InputStream getContentStream()
                                        throws javax.mail.MessagingException
Get all the bytes for this message. Overrides getContentStream() in MimeMessage. This method is ultimately used by the DataHandler to obtain the input stream for this message.

Overrides:
getContentStream in class javax.mail.internet.MimeMessage
Throws:
javax.mail.MessagingException
See Also:
MimeMessage.getContentStream()

getDataHandler

public javax.activation.DataHandler getDataHandler()
                                            throws javax.mail.MessagingException
Get the DataHandler object for this message.

Specified by:
getDataHandler in interface javax.mail.Part
Overrides:
getDataHandler in class javax.mail.internet.MimeMessage
Returns:
DataHandler for the content
Throws:
javax.mail.MessagingException

setDataHandler

public void setDataHandler(javax.activation.DataHandler content)
                    throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
This method provides the mechanism to set this part's content. The given DataHandler object should wrap the actual content.

Specified by:
setDataHandler in interface javax.mail.Part
Overrides:
setDataHandler in class javax.mail.internet.MimeMessage
Parameters:
content - The DataHandler for the content.
Throws:
javax.mail.MessagingException

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException,
                    javax.mail.MessagingException
Write out the bytes into the given outputstream.

Specified by:
writeTo in interface javax.mail.Part
Overrides:
writeTo in class javax.mail.internet.MimeMessage
Throws:
java.io.IOException - if an error occurs writing to the stream or if an error is generated by the javax.activation layer.
javax.mail.MessagingException - if an error occurs fetching the data to be written
See Also:
DataHandler.writeTo(java.io.OutputStream)

getHeader

public java.lang.String[] getHeader(java.lang.String name)
                             throws javax.mail.MessagingException
Get the named header.

Specified by:
getHeader in interface javax.mail.Part
Overrides:
getHeader in class javax.mail.internet.MimeMessage
Parameters:
name - name of header
Returns:
array of headers
Throws:
javax.mail.MessagingException
See Also:
MimeUtility

getHeader

public java.lang.String getHeader(java.lang.String name,
                                  java.lang.String delimiter)
                           throws javax.mail.MessagingException
Get the named header.

Specified by:
getHeader in interface javax.mail.internet.MimePart
Overrides:
getHeader in class javax.mail.internet.MimeMessage
Parameters:
name - the name of this header
delimiter - separator between values
Returns:
the value fields for all headers with this name
Throws:
javax.mail.MessagingException

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
               throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Set the value for this header_name. Replaces all existing header values with this new value. Note that RFC 822 headers must contain only US-ASCII characters, so a header that contains non US-ASCII characters must have been encoded by the caller as per the rules of RFC 2047.

Specified by:
setHeader in interface javax.mail.Part
Overrides:
setHeader in class javax.mail.internet.MimeMessage
Parameters:
name - header name
value - header value
Throws:
javax.mail.MessagingException
See Also:
MimeUtility

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
               throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Add this value to the existing values for this header_name. Note that RFC 822 headers must contain only US-ASCII characters, so a header that contains non US-ASCII characters must have been encoded as per the rules of RFC 2047.

Specified by:
addHeader in interface javax.mail.Part
Overrides:
addHeader in class javax.mail.internet.MimeMessage
Parameters:
name - header name
value - header value
Throws:
javax.mail.MessagingException
See Also:
MimeUtility

removeHeader

public void removeHeader(java.lang.String name)
                  throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Remove all headers with this name.

Specified by:
removeHeader in interface javax.mail.Part
Overrides:
removeHeader in class javax.mail.internet.MimeMessage
Parameters:
name - the name of this header
Throws:
javax.mail.MessagingException

getAllHeaders

public java.util.Enumeration getAllHeaders()
                                    throws javax.mail.MessagingException
Get all headers.

Specified by:
getAllHeaders in interface javax.mail.Part
Overrides:
getAllHeaders in class javax.mail.internet.MimeMessage
Returns:
array of header objects
Throws:
javax.mail.MessagingException
See Also:
MimeUtility

getMatchingHeaders

public java.util.Enumeration getMatchingHeaders(java.lang.String[] names)
                                         throws javax.mail.MessagingException
Get matching headers.

Specified by:
getMatchingHeaders in interface javax.mail.Part
Overrides:
getMatchingHeaders in class javax.mail.internet.MimeMessage
Returns:
enumeration of Header objects
Throws:
javax.mail.MessagingException

getNonMatchingHeaders

public java.util.Enumeration getNonMatchingHeaders(java.lang.String[] names)
                                            throws javax.mail.MessagingException
Get non-matching headers.

Specified by:
getNonMatchingHeaders in interface javax.mail.Part
Overrides:
getNonMatchingHeaders in class javax.mail.internet.MimeMessage
Returns:
enumeration of Header objects
Throws:
javax.mail.MessagingException

addHeaderLine

public void addHeaderLine(java.lang.String line)
                   throws javax.mail.MessagingException
Description copied from class: javax.mail.internet.MimeMessage
Add a raw RFC 822 header-line.

Specified by:
addHeaderLine in interface javax.mail.internet.MimePart
Overrides:
addHeaderLine in class javax.mail.internet.MimeMessage
Throws:
javax.mail.IllegalWriteException - if the underlying implementation does not support modification
javax.mail.MessagingException

getAllHeaderLines

public java.util.Enumeration getAllHeaderLines()
                                        throws javax.mail.MessagingException
Get all header-lines.

Specified by:
getAllHeaderLines in interface javax.mail.internet.MimePart
Overrides:
getAllHeaderLines in class javax.mail.internet.MimeMessage
Throws:
javax.mail.MessagingException

getMatchingHeaderLines

public java.util.Enumeration getMatchingHeaderLines(java.lang.String[] names)
                                             throws javax.mail.MessagingException
Get all matching header-lines.

Specified by:
getMatchingHeaderLines in interface javax.mail.internet.MimePart
Overrides:
getMatchingHeaderLines in class javax.mail.internet.MimeMessage
Throws:
javax.mail.MessagingException

getNonMatchingHeaderLines

public java.util.Enumeration getNonMatchingHeaderLines(java.lang.String[] names)
                                                throws javax.mail.MessagingException
Get all non-matching headerlines.

Specified by:
getNonMatchingHeaderLines in interface javax.mail.internet.MimePart
Overrides:
getNonMatchingHeaderLines in class javax.mail.internet.MimeMessage
Throws:
javax.mail.MessagingException

getFlags

public javax.mail.Flags getFlags()
                          throws javax.mail.MessagingException
Get the Flags for this message.

Overrides:
getFlags in class javax.mail.internet.MimeMessage
Returns:
Flags object containing the flags for this message
Throws:
javax.mail.MessagingException
See Also:
Flags

isSet

public boolean isSet(javax.mail.Flags.Flag flag)
              throws javax.mail.MessagingException
Test if the given Flags are set in this message.

Overrides:
isSet in class javax.mail.internet.MimeMessage
Parameters:
flag - the flag
Returns:
value of the specified flag for this message
Throws:
javax.mail.MessagingException
See Also:
Flags.Flag, Flags.Flag.ANSWERED, Flags.Flag.DELETED, Flags.Flag.DRAFT, Flags.Flag.FLAGGED, Flags.Flag.RECENT, Flags.Flag.SEEN

setFlags

public void setFlags(javax.mail.Flags flag,
                     boolean set)
              throws javax.mail.MessagingException
Set/Unset the given flags in this message.

Overrides:
setFlags in class javax.mail.internet.MimeMessage
Parameters:
flag - Flags object containing the flags to be set
set - the value to be set
Throws:
javax.mail.MessagingException
See Also:
MessageChangedEvent

setPeek

public void setPeek(boolean peek)
Set whether or not to use the PEEK variant of FETCH when fetching message content.

Since:
JavaMail 1.3.3

getPeek

public boolean getPeek()
Get whether or not to use the PEEK variant of FETCH when fetching message content.

Since:
JavaMail 1.3.3

invalidateHeaders

public void invalidateHeaders()
Invalidate cached header and envelope information for this message. Subsequent accesses of this information will cause it to be fetched from the server.

Since:
JavaMail 1.3.3