| Modifier and Type | Class and Description |
|---|---|
static class |
MimeMessage.RecipientType
Extends
Message.RecipientType to support addition recipient types. |
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
content
This message's content (unless sourced from a SharedInputStream).
|
protected java.io.InputStream |
contentStream
If the data for this message was supplied by a
SharedInputStream
then this is another such stream representing the content of this message;
if this field is non-null, then content will be null. |
protected javax.activation.DataHandler |
dh
The
DataHandler for this Message's content. |
protected Flags |
flags
This message's flags.
|
protected InternetHeaders |
headers
This message's headers.
|
protected boolean |
modified
Flag indicating that the message has been modified; set to true when
an empty message is created or when
saveChanges() is called. |
protected boolean |
saved
Flag indicating that the message has been saved.
|
ATTACHMENT, INLINE| Modifier | Constructor and Description |
|---|---|
protected |
MimeMessage(Folder folder,
java.io.InputStream in,
int number)
Create a MimeMessage by reading an parsing the data from the supplied stream.
|
protected |
MimeMessage(Folder folder,
int number)
Create an new MimeMessage in the supplied
Folder and message number. |
protected |
MimeMessage(Folder folder,
InternetHeaders headers,
byte[] content,
int number)
Create a MimeMessage with the supplied headers and content.
|
|
MimeMessage(MimeMessage message)
Copy a MimeMessage.
|
|
MimeMessage(Session session)
Create a new MimeMessage.
|
|
MimeMessage(Session session,
java.io.InputStream in)
Create a MimeMessage by reading an parsing the data from the supplied stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFrom(Address[] addresses)
Add a set of addresses to the existing From header.
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Add a new value to an existing header.
|
void |
addHeaderLine(java.lang.String line) |
void |
addRecipients(Message.RecipientType type,
Address[] address)
Add a list of addresses to a target recipient list.
|
void |
addRecipients(Message.RecipientType type,
java.lang.String address)
Add an address to a target recipient list by string name.
|
protected InternetHeaders |
createInternetHeaders(java.io.InputStream in) |
protected MimeMessage |
createMimeMessage(Session session)
Method used to create a new MimeMessage instance.
|
java.util.Enumeration |
getAllHeaderLines() |
java.util.Enumeration |
getAllHeaders()
Retrieve the complete list of message headers, as an enumeration.
|
Address[] |
getAllRecipients()
Retrieve all of the recipients defined for this message.
|
java.lang.Object |
getContent() |
java.lang.String |
getContentID()
Retrieve the value of the "Content-ID" header.
|
java.lang.String[] |
getContentLanguage() |
java.lang.String |
getContentMD5() |
protected java.io.InputStream |
getContentStream() |
java.lang.String |
getContentType()
Returns the current content type (defined in the "Content-Type"
header.
|
javax.activation.DataHandler |
getDataHandler() |
java.lang.String |
getDescription() |
java.lang.String |
getDisposition()
Retrieve the message "Content-Disposition" header field.
|
java.lang.String |
getEncoding()
Decode the Content-Transfer-Encoding header to determine
the transfer encoding type.
|
java.lang.String |
getFileName() |
Flags |
getFlags()
Return a copy the flags associated with this message.
|
Address[] |
getFrom()
Get the message "From" addresses.
|
java.lang.String[] |
getHeader(java.lang.String name)
Retrieve all headers that match a given name.
|
java.lang.String |
getHeader(java.lang.String name,
java.lang.String delimiter)
Get all headers that match a particular name, as a single string.
|
java.io.InputStream |
getInputStream() |
int |
getLineCount()
Retrieve the line count for the current message.
|
java.util.Enumeration |
getMatchingHeaderLines(java.lang.String[] names) |
java.util.Enumeration |
getMatchingHeaders(java.lang.String[] names) |
java.lang.String |
getMessageID() |
java.util.Enumeration |
getNonMatchingHeaderLines(java.lang.String[] names) |
java.util.Enumeration |
getNonMatchingHeaders(java.lang.String[] names) |
java.io.InputStream |
getRawInputStream() |
java.util.Date |
getReceivedDate()
Get the message received date.
|
Address[] |
getRecipients(Message.RecipientType type)
Gets the recipients by type.
|
Address[] |
getReplyTo()
Get the ReplyTo address information.
|
Address |
getSender()
Return the "Sender" header as an address.
|
java.util.Date |
getSentDate()
Get the value of the "Date" header field.
|
int |
getSize()
Return the content size of this message.
|
java.lang.String |
getSubject()
Returns the value of the "Subject" header.
|
boolean |
isMimeType(java.lang.String type)
Tests to see if this message has a mime-type match with the
given type name.
|
boolean |
isSet(Flags.Flag flag)
Check whether the supplied flag is set.
|
protected void |
parse(java.io.InputStream in)
|
void |
removeHeader(java.lang.String name)
Remove a header with the given name.
|
Message |
reply(boolean replyToAll)
Create a new message suitable as a reply to this message with all headers set
up appropriately.
|
void |
saveChanges()
Saves any changes on this message.
|
void |
setContent(Multipart part) |
void |
setContent(java.lang.Object content,
java.lang.String type) |
void |
setContentID(java.lang.String cid) |
void |
setContentLanguage(java.lang.String[] languages) |
void |
setContentMD5(java.lang.String md5) |
void |
setDataHandler(javax.activation.DataHandler handler) |
void |
setDescription(java.lang.String description) |
void |
setDescription(java.lang.String description,
java.lang.String charset) |
void |
setDisposition(java.lang.String disposition)
Set a new dispostion value for the "Content-Disposition" field.
|
void |
setFileName(java.lang.String name) |
void |
setFlags(Flags flag,
boolean set)
Set or clear a flag value.
|
void |
setFrom()
Set the "From" header using the value returned by
InternetAddress.getLocalAddress(javax.mail.Session). |
void |
setFrom(Address address)
Set the current message "From" recipient.
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Set a new value for a named header.
|
void |
setRecipients(Message.RecipientType type,
Address[] addresses)
Set a recipients list for a particular recipient type.
|
void |
setRecipients(Message.RecipientType type,
java.lang.String address)
Set a recipient field to a string address (which may be a
list or group type).
|
void |
setReplyTo(Address[] address)
Set the Reply-To field to the provided list of addresses.
|
void |
setSender(Address address)
Set the "Sender" header.
|
void |
setSentDate(java.util.Date sent)
Set the message sent date.
|
void |
setSubject(java.lang.String subject)
Set the value for the "Subject" header.
|
void |
setSubject(java.lang.String subject,
java.lang.String charset) |
void |
setText(java.lang.String text) |
void |
setText(java.lang.String text,
java.lang.String charset) |
void |
setText(java.lang.String text,
java.lang.String charset,
java.lang.String subtype) |
protected void |
updateHeaders()
Update the internet headers so that they make sense.
|
protected void |
updateMessageID()
Update the message identifier after headers have been updated.
|
void |
writeTo(java.io.OutputStream out)
Write the message out to a stream in RFC 822 format.
|
void |
writeTo(java.io.OutputStream out,
java.lang.String[] ignoreHeaders)
Write the message out to a target output stream, excluding the
specified message headers.
|
addRecipient, getFolder, getMessageNumber, isExpunged, match, setExpunged, setFlag, setMessageNumber, setRecipientprotected javax.activation.DataHandler dh
DataHandler for this Message's content.protected byte[] content
protected java.io.InputStream contentStream
SharedInputStream
then this is another such stream representing the content of this message;
if this field is non-null, then content will be null.protected InternetHeaders headers
protected Flags flags
protected boolean modified
saveChanges() is called.protected boolean saved
public MimeMessage(Session session)
headers and empty flags.
The modified flag is set.session - the session for this messagepublic MimeMessage(Session session, java.io.InputStream in) throws MessagingException
session - the session for this messagein - the stream to load fromMessagingException - if there is a problem reading or parsing the streampublic MimeMessage(MimeMessage message) throws MessagingException
message - the message to copyMessagingException - is there was a problem copying the messageprotected MimeMessage(Folder folder, int number)
Folder and message number.folder - the Folder that contains the new messagenumber - the message number of the new messageprotected MimeMessage(Folder folder, java.io.InputStream in, int number) throws MessagingException
folder - the folder for this messagein - the stream to load fromnumber - the message number of the new messageMessagingException - if there is a problem reading or parsing the streamprotected MimeMessage(Folder folder, InternetHeaders headers, byte[] content, int number) throws MessagingException
folder - the folder for this messageheaders - the headers for the new messagecontent - the content of the new messagenumber - the message number of the new messageMessagingException - if there is a problem reading or parsing the streamprotected void parse(java.io.InputStream in)
throws MessagingException
in - the stream to readMessagingException - if there was a problem parsing the streampublic Address[] getFrom() throws MessagingException
getFrom in class MessageMessagingExceptionpublic void setFrom(Address address) throws MessagingException
setFrom in class Messageaddress - The new "From" target.MessagingExceptionpublic void setFrom()
throws MessagingException
InternetAddress.getLocalAddress(javax.mail.Session).setFrom in class MessageMessagingException - if there was a problem setting the headerpublic void addFrom(Address[] addresses) throws MessagingException
addFrom in class Messageaddresses - The list to add.MessagingExceptionpublic Address getSender() throws MessagingException
MessagingException - if there was a problem parsing the headerpublic void setSender(Address address) throws MessagingException
address - the new Sender addressMessagingException - if there was a problem setting the headerpublic Address[] getRecipients(Message.RecipientType type) throws MessagingException
getRecipients in class Messagetype - The message RecipientType identifier.MessagingExceptionMessage.RecipientTypepublic Address[] getAllRecipients() throws MessagingException
getAllRecipients in class MessageMessagingExceptionpublic void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
setRecipients in class Messagetype - The type of recipient to set.addresses - The list of addresses.MessagingExceptionpublic void setRecipients(Message.RecipientType type, java.lang.String address) throws MessagingException
type - The type of recipient to set.address - The address string.MessagingExceptionpublic void addRecipients(Message.RecipientType type, Address[] address) throws MessagingException
addRecipients in class Messagetype - The target recipient type.address - An array of addresses to add.MessagingExceptionpublic void addRecipients(Message.RecipientType type, java.lang.String address) throws MessagingException
type - The target header type.address - The address to add.MessagingExceptionpublic Address[] getReplyTo() throws MessagingException
getReplyTo in class MessageMessagingExceptionpublic void setReplyTo(Address[] address) throws MessagingException
setReplyTo in class Messageaddress - The new field value.MessagingExceptionpublic java.lang.String getSubject()
throws MessagingException
getSubject in class MessageMessagingExceptionpublic void setSubject(java.lang.String subject)
throws MessagingException
setSubject in class Messagesubject - The new subject value.MessagingExceptionpublic void setSubject(java.lang.String subject,
java.lang.String charset)
throws MessagingException
MessagingExceptionpublic java.util.Date getSentDate()
throws MessagingException
getSentDate in class MessageMessagingExceptionpublic void setSentDate(java.util.Date sent)
throws MessagingException
setSentDate in class Messagesent - The new sent date value.MessagingExceptionpublic java.util.Date getReceivedDate()
throws MessagingException
getReceivedDate in class MessageMessagingExceptionpublic int getSize()
throws MessagingException
getSize in interface PartMessagingExceptionpublic int getLineCount()
throws MessagingException
getLineCount in interface PartMessagingExceptionpublic java.lang.String getContentType()
throws MessagingException
getContentType in interface PartMessagingExceptionpublic boolean isMimeType(java.lang.String type)
throws MessagingException
isMimeType in interface Parttype - The tested type name.MessagingExceptionpublic java.lang.String getDisposition()
throws MessagingException
getDisposition in interface PartMessagingExceptionpublic void setDisposition(java.lang.String disposition)
throws MessagingException
setDisposition in interface Partdisposition - The new disposition value.MessagingExceptionpublic java.lang.String getEncoding()
throws MessagingException
getEncoding in interface MimePartMessagingExceptionpublic java.lang.String getContentID()
throws MessagingException
getContentID in interface MimePartMessagingExceptionpublic void setContentID(java.lang.String cid)
throws MessagingException
MessagingExceptionpublic java.lang.String getContentMD5()
throws MessagingException
getContentMD5 in interface MimePartMessagingExceptionpublic void setContentMD5(java.lang.String md5)
throws MessagingException
setContentMD5 in interface MimePartMessagingExceptionpublic java.lang.String getDescription()
throws MessagingException
getDescription in interface PartMessagingExceptionpublic void setDescription(java.lang.String description)
throws MessagingException
setDescription in interface PartMessagingExceptionpublic void setDescription(java.lang.String description,
java.lang.String charset)
throws MessagingException
MessagingExceptionpublic java.lang.String[] getContentLanguage()
throws MessagingException
getContentLanguage in interface MimePartMessagingExceptionpublic void setContentLanguage(java.lang.String[] languages)
throws MessagingException
setContentLanguage in interface MimePartMessagingExceptionpublic java.lang.String getMessageID()
throws MessagingException
MessagingExceptionpublic java.lang.String getFileName()
throws MessagingException
getFileName in interface PartMessagingExceptionpublic void setFileName(java.lang.String name)
throws MessagingException
setFileName in interface PartMessagingExceptionpublic java.io.InputStream getInputStream()
throws MessagingException,
java.io.IOException
getInputStream in interface PartMessagingExceptionjava.io.IOExceptionprotected java.io.InputStream getContentStream()
throws MessagingException
MessagingExceptionpublic java.io.InputStream getRawInputStream()
throws MessagingException
MessagingExceptionpublic javax.activation.DataHandler getDataHandler()
throws MessagingException
getDataHandler in interface PartMessagingExceptionpublic java.lang.Object getContent()
throws MessagingException,
java.io.IOException
getContent in interface PartMessagingExceptionjava.io.IOExceptionpublic void setDataHandler(javax.activation.DataHandler handler)
throws MessagingException
setDataHandler in interface PartMessagingExceptionpublic void setContent(java.lang.Object content,
java.lang.String type)
throws MessagingException
setContent in interface PartMessagingExceptionpublic void setText(java.lang.String text)
throws MessagingException
setText in interface MimePartsetText in interface PartMessagingExceptionpublic void setText(java.lang.String text,
java.lang.String charset)
throws MessagingException
setText in interface MimePartMessagingExceptionpublic void setText(java.lang.String text,
java.lang.String charset,
java.lang.String subtype)
throws MessagingException
setText in interface MimePartMessagingExceptionpublic void setContent(Multipart part) throws MessagingException
setContent in interface PartMessagingExceptionpublic Message reply(boolean replyToAll) throws MessagingException
MessageMessage.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.reply in class MessagereplyToAll - if true, indciates the message should be addressed to all recipients not just the senderMessagingException - if there was a problem accessing the storepublic void writeTo(java.io.OutputStream out)
throws MessagingException,
java.io.IOException
writeTo in interface Partout - The target output stream.MessagingExceptionjava.io.IOExceptionpublic void writeTo(java.io.OutputStream out,
java.lang.String[] ignoreHeaders)
throws MessagingException,
java.io.IOException
out - The target output stream.ignoreHeaders - An array of header types to ignore. This can be null, which means
write out all headers.MessagingExceptionjava.io.IOExceptionpublic java.lang.String[] getHeader(java.lang.String name)
throws MessagingException
getHeader in interface Partname - The target name.MessagingExceptionpublic java.lang.String getHeader(java.lang.String name,
java.lang.String delimiter)
throws MessagingException
getHeader in interface MimePartname - The source header name.delimiter - The delimiter string to be used between headers. If null, only
the first is returned.MessagingExceptionpublic void setHeader(java.lang.String name,
java.lang.String value)
throws MessagingException
setHeader in interface Partname - The name of the target header.value - The new value for the header.MessagingExceptionpublic void addHeader(java.lang.String name,
java.lang.String value)
throws MessagingException
addHeader in interface Partname - The name of the target header.value - The removed header.MessagingExceptionpublic void removeHeader(java.lang.String name)
throws MessagingException
removeHeader in interface Partname - The name of the removed header.MessagingExceptionpublic java.util.Enumeration getAllHeaders()
throws MessagingException
getAllHeaders in interface PartMessagingExceptionpublic java.util.Enumeration getMatchingHeaders(java.lang.String[] names)
throws MessagingException
getMatchingHeaders in interface PartMessagingExceptionpublic java.util.Enumeration getNonMatchingHeaders(java.lang.String[] names)
throws MessagingException
getNonMatchingHeaders in interface PartMessagingExceptionpublic void addHeaderLine(java.lang.String line)
throws MessagingException
addHeaderLine in interface MimePartMessagingExceptionpublic java.util.Enumeration getAllHeaderLines()
throws MessagingException
getAllHeaderLines in interface MimePartMessagingExceptionpublic java.util.Enumeration getMatchingHeaderLines(java.lang.String[] names)
throws MessagingException
getMatchingHeaderLines in interface MimePartMessagingExceptionpublic java.util.Enumeration getNonMatchingHeaderLines(java.lang.String[] names)
throws MessagingException
getNonMatchingHeaderLines in interface MimePartMessagingExceptionpublic Flags getFlags() throws MessagingException
MessagegetFlags in class MessageMessagingException - if there was a problem accessing the storepublic boolean isSet(Flags.Flag flag) throws MessagingException
MessageMessage.getFlags().isSet in class Messageflag - the flags to check forMessagingException - if there was a problem accessing the storepublic void setFlags(Flags flag, boolean set) throws MessagingException
setFlags in class Messageflags - The set of flags to effect.set - The value to set the flag to (true or false).MessagingExceptionpublic void saveChanges()
throws MessagingException
saveChanges in class MessageMessagingExceptionprotected void updateHeaders()
throws MessagingException
MessagingExceptionprotected InternetHeaders createInternetHeaders(java.io.InputStream in) throws MessagingException
MessagingExceptionprotected void updateMessageID()
throws MessagingException
MessagingExceptionprotected MimeMessage createMimeMessage(Session session) throws MessagingException
session - The session associated with this message.MessagingException - if the MimeMessage could not be created