|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.mail.Message
javax.mail.internet.MimeMessage
public class MimeMessage
| Nested Class Summary | |
|---|---|
static class |
MimeMessage.RecipientType
Extends Message.RecipientType to support addition recipient types. |
| Field Summary | |
|---|---|
protected byte[] |
content
This message's content (unless sourced from a SharedInputStream). |
protected 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 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. |
| Fields inherited from class javax.mail.Message |
|---|
expunged, folder, msgnum, session |
| Fields inherited from interface javax.mail.Part |
|---|
ATTACHMENT, INLINE |
| Constructor Summary | |
|---|---|
protected |
MimeMessage(Folder folder,
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,
InputStream in)
Create a MimeMessage by reading an parsing the data from the supplied stream. |
| Method Summary | |
|---|---|
void |
addFrom(Address[] addresses)
Add a set of addresses to the existing From header. |
void |
addHeader(String name,
String value)
Add a new value to an existing header. |
void |
addHeaderLine(String line)
|
void |
addRecipients(Message.RecipientType type,
Address[] address)
Add a list of addresses to a target recipient list. |
void |
addRecipients(Message.RecipientType type,
String address)
Add an address to a target recipient list by string name. |
protected InternetHeaders |
createInternetHeaders(InputStream in)
|
Enumeration |
getAllHeaderLines()
|
Enumeration |
getAllHeaders()
Retrieve the complete list of message headers, as an enumeration. |
Address[] |
getAllRecipients()
Retrieve all of the recipients defined for this message. |
Object |
getContent()
|
String |
getContentID()
Retrieve the value of the "Content-ID" header. |
String[] |
getContentLanguage()
|
String |
getContentMD5()
|
protected InputStream |
getContentStream()
|
String |
getContentType()
Returns the current content type (defined in the "Content-Type" header. |
DataHandler |
getDataHandler()
|
String |
getDescription()
|
String |
getDisposition()
Retrieve the message "Content-Disposition" header field. |
String |
getEncoding()
Decode the Content-Transfer-Encoding header to determine the transfer encoding type. |
String |
getFileName()
|
Flags |
getFlags()
Return a copy the flags associated with this message. |
Address[] |
getFrom()
Get the message "From" addresses. |
String[] |
getHeader(String name)
Retrieve all headers that match a given name. |
String |
getHeader(String name,
String delimiter)
Get all headers that match a particular name, as a single string. |
InputStream |
getInputStream()
|
int |
getLineCount()
Retrieve the line count for the current message. |
Enumeration |
getMatchingHeaderLines(String[] names)
|
Enumeration |
getMatchingHeaders(String[] names)
|
String |
getMessageID()
|
Enumeration |
getNonMatchingHeaderLines(String[] names)
|
Enumeration |
getNonMatchingHeaders(String[] names)
|
InputStream |
getRawInputStream()
|
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. |
Date |
getSentDate()
Get the value of the "Date" header field. |
int |
getSize()
Return the content size of this message. |
String |
getSubject()
Returns the value of the "Subject" header. |
boolean |
isMimeType(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(InputStream in)
Parse the supplied stream and initialize headers and content appropriately. |
void |
removeHeader(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(Object content,
String type)
|
void |
setContentID(String cid)
|
void |
setContentLanguage(String[] languages)
|
void |
setContentMD5(String md5)
|
void |
setDataHandler(DataHandler handler)
|
void |
setDescription(String description)
|
void |
setDescription(String description,
String charset)
|
void |
setDisposition(String disposition)
Set a new dispostion value for the "Content-Disposition" field. |
void |
setFileName(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(String name,
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,
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(Date sent)
Set the message sent date. |
void |
setSubject(String subject)
Set the value for the "Subject" header. |
void |
setSubject(String subject,
String charset)
|
void |
setText(String text)
|
void |
setText(String text,
String charset)
|
protected void |
updateHeaders()
Update the internet headers so that they make sense. |
void |
writeTo(OutputStream out)
Write the message out to a stream in RFC 822 format. |
void |
writeTo(OutputStream out,
String[] ignoreHeaders)
Write the message out to a target output stream, excluding the specified message headers. |
| Methods inherited from class javax.mail.Message |
|---|
addRecipient, getFolder, getMessageNumber, isExpunged, match, setExpunged, setFlag, setMessageNumber, setRecipient |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DataHandler dh
DataHandler for this Message's content.
protected byte[] content
protected 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
| Constructor Detail |
|---|
public MimeMessage(Session session)
headers and empty flags.
The modified flag is set.
session - the session for this message
public MimeMessage(Session session,
InputStream in)
throws MessagingException
session - the session for this messagein - the stream to load from
MessagingException - if there is a problem reading or parsing the stream
public MimeMessage(MimeMessage message)
throws MessagingException
message - the message to copy
MessagingException - is there was a problem copying the message
protected MimeMessage(Folder folder,
int number)
Folder and message number.
folder - the Folder that contains the new messagenumber - the message number of the new message
protected MimeMessage(Folder folder,
InputStream in,
int number)
throws MessagingException
folder - the folder for this messagein - the stream to load fromnumber - the message number of the new message
MessagingException - if there is a problem reading or parsing the stream
protected 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 message
MessagingException - if there is a problem reading or parsing the stream| Method Detail |
|---|
protected void parse(InputStream in)
throws MessagingException
headers and content appropriately.
in - the stream to read
MessagingException - if there was a problem parsing the stream
public Address[] getFrom()
throws MessagingException
getFrom in class MessageMessagingException
public void setFrom(Address address)
throws MessagingException
setFrom in class Messageaddress - The new "From" target.
MessagingException
public void setFrom()
throws MessagingException
InternetAddress.getLocalAddress(javax.mail.Session).
setFrom in class MessageMessagingException - if there was a problem setting the header
public void addFrom(Address[] addresses)
throws MessagingException
addFrom in class Messageaddresses - The list to add.
MessagingException
public Address getSender()
throws MessagingException
MessagingException - if there was a problem parsing the header
public void setSender(Address address)
throws MessagingException
address - the new Sender address
MessagingException - if there was a problem setting the header
public Address[] getRecipients(Message.RecipientType type)
throws MessagingException
getRecipients in class Messagetype - The message RecipientType identifier.
MessagingExceptionMessage.RecipientType
public Address[] getAllRecipients()
throws MessagingException
getAllRecipients in class MessageMessagingException
public void setRecipients(Message.RecipientType type,
Address[] addresses)
throws MessagingException
setRecipients in class Messagetype - The type of recipient to set.addresses - The list of addresses.
MessagingException
public void setRecipients(Message.RecipientType type,
String address)
throws MessagingException
type - The type of recipient to set.address - The address string.
MessagingException
public void addRecipients(Message.RecipientType type,
Address[] address)
throws MessagingException
addRecipients in class Messagetype - The target recipient type.address - An array of addresses to add.
MessagingException
public void addRecipients(Message.RecipientType type,
String address)
throws MessagingException
type - The target header type.address - The address to add.
MessagingException
public Address[] getReplyTo()
throws MessagingException
getReplyTo in class MessageMessagingException
public void setReplyTo(Address[] address)
throws MessagingException
setReplyTo in class Messageaddress - The new field value.
MessagingException
public String getSubject()
throws MessagingException
getSubject in class MessageMessagingException
public void setSubject(String subject)
throws MessagingException
setSubject in class Messagesubject - The new subject value.
MessagingException
public void setSubject(String subject,
String charset)
throws MessagingException
MessagingException
public Date getSentDate()
throws MessagingException
getSentDate in class MessageMessagingException
public void setSentDate(Date sent)
throws MessagingException
setSentDate in class Messagesent - The new sent date value.
MessagingException
public Date getReceivedDate()
throws MessagingException
getReceivedDate in class MessageMessagingException
public int getSize()
throws MessagingException
getSize in interface PartMessagingException
public int getLineCount()
throws MessagingException
getLineCount in interface PartMessagingException
public String getContentType()
throws MessagingException
getContentType in interface PartMessagingException
public boolean isMimeType(String type)
throws MessagingException
isMimeType in interface Parttype - The tested type name.
MessagingException
public String getDisposition()
throws MessagingException
getDisposition in interface PartMessagingException
public void setDisposition(String disposition)
throws MessagingException
setDisposition in interface Partdisposition - The new disposition value.
MessagingException
public String getEncoding()
throws MessagingException
getEncoding in interface MimePartMessagingException
public String getContentID()
throws MessagingException
getContentID in interface MimePartMessagingException
public void setContentID(String cid)
throws MessagingException
MessagingException
public String getContentMD5()
throws MessagingException
getContentMD5 in interface MimePartMessagingException
public void setContentMD5(String md5)
throws MessagingException
setContentMD5 in interface MimePartMessagingException
public String getDescription()
throws MessagingException
getDescription in interface PartMessagingException
public void setDescription(String description)
throws MessagingException
setDescription in interface PartMessagingException
public void setDescription(String description,
String charset)
throws MessagingException
MessagingException
public String[] getContentLanguage()
throws MessagingException
getContentLanguage in interface MimePartMessagingException
public void setContentLanguage(String[] languages)
throws MessagingException
setContentLanguage in interface MimePartMessagingException
public String getMessageID()
throws MessagingException
MessagingException
public String getFileName()
throws MessagingException
getFileName in interface PartMessagingException
public void setFileName(String name)
throws MessagingException
setFileName in interface PartMessagingException
public InputStream getInputStream()
throws MessagingException,
IOException
getInputStream in interface PartMessagingException
IOException
protected InputStream getContentStream()
throws MessagingException
MessagingException
public InputStream getRawInputStream()
throws MessagingException
MessagingException
public DataHandler getDataHandler()
throws MessagingException
getDataHandler in interface PartMessagingException
public Object getContent()
throws MessagingException,
IOException
getContent in interface PartMessagingException
IOException
public void setDataHandler(DataHandler handler)
throws MessagingException
setDataHandler in interface PartMessagingException
public void setContent(Object content,
String type)
throws MessagingException
setContent in interface PartMessagingException
public void setText(String text)
throws MessagingException
setText in interface MimePartsetText in interface PartMessagingException
public void setText(String text,
String charset)
throws MessagingException
setText in interface MimePartMessagingException
public void setContent(Multipart part)
throws MessagingException
setContent in interface PartMessagingException
public 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 sender
MessagingException - if there was a problem accessing the store
public void writeTo(OutputStream out)
throws MessagingException,
IOException
writeTo in interface Partout - The target output stream.
MessagingException
IOException
public void writeTo(OutputStream out,
String[] ignoreHeaders)
throws MessagingException,
IOException
out - The target output stream.ignoreHeaders - An array of header types to ignore. This can be null, which means
write out all headers.
MessagingException
IOException
public String[] getHeader(String name)
throws MessagingException
getHeader in interface Partname - The target name.
MessagingException
public String getHeader(String name,
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.
MessagingException
public void setHeader(String name,
String value)
throws MessagingException
setHeader in interface Partname - The name of the target header.value - The new value for the header.
MessagingException
public void addHeader(String name,
String value)
throws MessagingException
addHeader in interface Partname - The name of the target header.value - The removed header.
MessagingException
public void removeHeader(String name)
throws MessagingException
removeHeader in interface Partname - The name of the removed header.
MessagingException
public Enumeration getAllHeaders()
throws MessagingException
getAllHeaders in interface PartMessagingException
public Enumeration getMatchingHeaders(String[] names)
throws MessagingException
getMatchingHeaders in interface PartMessagingException
public Enumeration getNonMatchingHeaders(String[] names)
throws MessagingException
getNonMatchingHeaders in interface PartMessagingException
public void addHeaderLine(String line)
throws MessagingException
addHeaderLine in interface MimePartMessagingException
public Enumeration getAllHeaderLines()
throws MessagingException
getAllHeaderLines in interface MimePartMessagingException
public Enumeration getMatchingHeaderLines(String[] names)
throws MessagingException
getMatchingHeaderLines in interface MimePartMessagingException
public Enumeration getNonMatchingHeaderLines(String[] names)
throws MessagingException
getNonMatchingHeaderLines in interface MimePartMessagingException
public Flags getFlags()
throws MessagingException
Message
getFlags in class MessageMessagingException - if there was a problem accessing the store
public boolean isSet(Flags.Flag flag)
throws MessagingException
MessageMessage.getFlags().
isSet in class Messageflag - the flags to check for
MessagingException - if there was a problem accessing the store
public 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).
MessagingException
public void saveChanges()
throws MessagingException
saveChanges in class MessageMessagingException
protected void updateHeaders()
throws MessagingException
MessagingException
protected InternetHeaders createInternetHeaders(InputStream in)
throws MessagingException
MessagingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||