Message abstract class and the MimePart
interface. Clients wanting to create new MIME style messages will instantiate an empty MimeMessage object and then fill it with appropriate attributes and content.
Service providers that implement MIME compliant backend stores may want to subclass MimeMessage and override certain methods to provide specific implementations. The simplest case is probably a provider that generates a MIME style input stream and leaves the parsing of the stream to this class.
MimeMessage uses the InternetHeaders class to parse and
store the top level RFC 822 headers of a message.
The mail.mime.address.strict session property controls
the parsing of address headers. By default, strict parsing of address
headers is done. If this property is set to "false",
strict parsing is not done and many illegal addresses that sometimes
occur in real messages are allowed. See the InternetAddress
class for details.
RFC 822 header fields must contain only
US-ASCII characters. MIME allows non ASCII characters to be present
in certain portions of certain headers, by encoding those characters.
RFC 2047 specifies the rules for doing this. The MimeUtility
class provided in this package can be used to to achieve this.
Callers of the setHeader, addHeader, and
addHeaderLine methods are responsible for enforcing
the MIME requirements for the specified headers. In addition, these
header fields must be folded (wrapped) before being sent if they
exceed the line length limitation for the transport (1000 bytes for
SMTP). Received headers may have been folded. The application is
responsible for folding and unfolding headers as appropriate.
javax.mail.internet.MimeUtility, javax.mail.Part, javax.mail.Message, javax.mail.internet.MimePart, javax.mail.internet.InternetAddress
| Modifier and Type | Class and Description |
|---|---|
| public static class | MimeMessage.RecipientType
This inner class extends the javax.mail.Message.RecipientType class to add additional RecipientTypes. |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private static final Flags | |
| protected Object | cachedContent
If our content is a Multipart or Message object, we save it the first time it's created by parsing a stream so that changes to the contained objects will not be lost. |
| protected byte[] | content
Byte array that holds the bytes of this Message's content. |
| protected InputStream | contentStream
If the data for this message was supplied by an
InputStream that implements the SharedInputStream interface,
|
| protected DataHandler | dh
The DataHandler object representing this Message's content. |
| protected Flags | flags
The Flags for this message. |
| protected InternetHeaders | headers
The InternetHeaders object that stores the header of this message. |
| private static final MailDateFormat | |
| protected boolean | modified
A flag indicating whether the message has been modified. |
| protected boolean | saved
Does the |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MimeMessage(Session
Session object for this message session, InputStream the message input stream is)Constructs a MimeMessage by reading and parsing the data from the specified MIME InputStream. |
| public | MimeMessage(MimeMessage
the message to copy content from source)Constructs a new MimeMessage with content initialized from the
|
| protected | MimeMessage(Folder
the Folder this message is from folder, int the number of this message msgnum)Constructs an empty MimeMessage object with the given Folder and message number. |
| protected | MimeMessage(Folder
The containing folder. folder, InputStream the message input stream is, int Message number of this message within its folder msgnum)Constructs a MimeMessage by reading and parsing the data from the specified MIME InputStream. |
| protected | MimeMessage(Folder
The containing folder. folder, InternetHeaders The headers headers, byte[] The message content content, int Message number of this message within its folder msgnum)Constructs a MimeMessage from the given InternetHeaders object and content. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | addFrom(Address[]
the senders of this message addresses)Implements abstract javax. |
| public void | addHeader(String
header name name, String header value value)Implements javax. |
| public void | addHeaderLine(String
the line to add line)Implements javax. |
| public void | addRecipients(Message.
Recipient type type,Addresses addresses)Implements abstract javax. |
| public void | addRecipients(Message.
Recipient type type,Addresses addresses)Add the given addresses to the specified recipient type. |
| protected InternetHeaders | Returns: an InternetHeaders objectthe InputStream to read the headers from is)Create and return an InternetHeaders object that loads the headers from the given InputStream. |
| protected MimeMessage | Returns: the new MimeMessage objectthe Session to use for the new message session)Create and return a MimeMessage object. |
| private Address[] | eliminateDuplicates(List<Address> v, Address[] addrs)
Check addrs for any duplicates that may already be in v. Return a new array without the duplicates. |
| private Address[] | |
| public Enumeration | getAllHeaderLines()
Implements javax. |
| public Enumeration | Returns: array of header objectsImplements javax. |
| public Address[] | Returns: array of Address objectsOverrides javax. |
| public Object | Returns: ObjectImplements javax. |
| public String | Returns: content-IDImplements javax. |
| public String[] | Returns: value of content-language header.Implements javax. |
| public String | Returns: content-MD5Implements javax. |
| protected InputStream | Returns: an InputStream containing the raw bytesProduce the raw bytes of the content. |
| public String | Returns: The ContentType of this partImplements javax. |
| public synchronized DataHandler | getDataHandler()
Implements javax. |
| public String | Returns: content-descriptionImplements javax. |
| public String | Returns: disposition of this part, or null if unknownImplements javax. |
| public String | Returns: content-transfer-encodingImplements javax. |
| public String | Returns: filenameImplements javax. |
| public synchronized Flags | Returns: Flags object containing the flags for this messageImplements abstract javax. Flags object containing the flags for
this message.
|
| public Address[] | Returns: Address objectImplements abstract javax. |
| public String[] | Returns: array of headersname of header name)Implements javax. |
| public String | Returns: the value fields for all headers with this namethe name of this header name, String separator between values delimiter)Implements javax. |
| private String | |
| public InputStream | Returns: an InputStreamImplements javax. |
| public int | Returns: number of lines in the content.Implements javax. |
| public Enumeration | getMatchingHeaderLines(String[]
the headers to return names)Implements javax. |
| public Enumeration | getMatchingHeaders(String[]
the headers to match names)Implements javax. |
| public String | |
| public Enumeration | getNonMatchingHeaderLines(String[]
the headers to not return names)Implements javax. |
| public Enumeration | getNonMatchingHeaders(String[]
the headers to not match names)Implements javax. |
| public InputStream | Returns: an InputStream containing the raw bytesReturn an InputStream to the raw data with any Content-Transfer-Encoding intact. |
| public Date | Returns: the date this message was receivedImplements abstract javax. |
| public Address[] | Returns: array of Address objectsType of recepient typeImplements abstract javax. |
| public Address[] | getReplyTo()
Overrides javax. |
| public Address | |
| public Date | Returns: The sent DateImplements abstract javax. |
| public int | Returns: size of content in bytesImplements javax. |
| public String | Returns: SubjectImplements abstract javax. |
| private void | |
| public boolean | Returns: true if it matches the MIME typethe MIME type to check mimeType)Implements javax. |
| public synchronized boolean | Returns: value of the specified flag for this messagethe flag flagOverrides javax. flag
argument is set in this message.
|
| protected void | parse(InputStream
The message input stream is)Parse the InputStream setting the |
| public void | removeHeader(String
the name of this header name)Implements javax. |
| public Message | Returns: the reply Messagereply should be sent to all recipients
of this message replyToAll)Implements abstract javax. |
| public Message | Returns: the reply Messagereply should be sent to all recipients
of this message replyToAll, boolean set the ANSWERED flag in this message? setAnswered)Get a new Message suitable for a reply to this message. |
| public void | saveChanges()
Implements abstract javax. |
| private void | |
| public void | setContent(Object
the content object o, String Mime type of the object type)Implements javax. |
| public void | setContent(Multipart
The multipart object that is the Message's content mp)Implements javax. |
| public void | |
| public void | setContentLanguage(String[]
array of language tags languages)Implements javax. |
| public void | setContentMD5(String
the MD5 value md5)Implements javax. |
| public synchronized void | setDataHandler(DataHandler
The DataHandler for the content. dh)Implements javax. |
| public void | setDescription(String
content-description description)Implements javax. |
| public void | setDescription(String
Description description, String Charset for encoding charset)Set the "Content-Description" header field for this Message. |
| public void | setDisposition(String
disposition of this part disposition)Implements javax. |
| public void | setFileName(String
Filename to associate with this part filename)Implements javax. |
| public synchronized void | setFlags(Flags
Flags object containing the flags to be set flag, boolean the value to be set set)Implements abstract javax. |
| public void | setFrom(Address
the sender of this message address)Implements abstract javax. |
| public void | |
| public void | setFrom()
Implements abstract javax. InternetAddress.getLocalAddress method.
|
| public void | setHeader(String
header name name, String header value value)Implements javax. |
| public void | setRecipients(Message.
Recipient type type,Addresses addresses)Implements abstract javax. |
| public void | setRecipients(Message.
Recipient type type,Addresses addresses)Set the specified recipient type to the given addresses. |
| public void | setReplyTo(Address[]
addresses to which replies should be directed addresses)Overrides javax. |
| public void | |
| public void | setSentDate(Date
the sent date of this message d)Implements abstract javax. |
| public void | setSubject(String
The subject subject)Implements abstract javax. |
| public void | |
| public void | setText(String
the text content to set text)Implements javax. |
| public void | setText(String
the text content to set text, String the charset to use for the text charset)Implements javax. |
| public void | setText(String
the text content to set text, String the charset to use for the text charset, String the MIME subtype to use (e.g., "html") subtype)Implements javax. |
| protected synchronized void | |
| protected void | |
| public void | writeTo(OutputStream
the stream to write to os)Implements javax. |
| public void | writeTo(OutputStream
the stream to write to os, String[] the headers to not include in the output ignoreList)Output the message as an RFC 822 format stream, without specified headers. |