|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.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)
Create a new set of internet headers from the InputStream |
protected MimeMessage |
createMimeMessage(Session session)
Method used to create a new MimeMessage instance. |
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()
Return a content object for this Part. |
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()
Returns a DataHandler instance for the content with in the Part. |
String |
getDescription()
Returns a description string for this Part. |
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()
Get a file name associated with this part. |
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()
Return an InputStream for accessing the Part content. |
int |
getLineCount()
Retrieve the line count for the current message. |
Enumeration |
getMatchingHeaderLines(String[] names)
|
Enumeration |
getMatchingHeaders(String[] names)
Return all headers that match the list of names as an Enumeration of Header objects. |
String |
getMessageID()
|
Enumeration |
getNonMatchingHeaderLines(String[] names)
|
Enumeration |
getNonMatchingHeaders(String[] names)
Return an Enumeration of all Headers except those that match the names given in the exclusion list. |
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)
Set a content object for this part. |
void |
setContentID(String cid)
|
void |
setContentLanguage(String[] languages)
|
void |
setContentMD5(String md5)
|
void |
setDataHandler(DataHandler handler)
Set a DataHandler for this part that defines the Part content. |
void |
setDescription(String description)
Set a descriptive string for this part. |
void |
setDescription(String description,
String charset)
|
void |
setDisposition(String disposition)
Set a new dispostion value for the "Content-Disposition" field. |
void |
setFileName(String name)
Set a descriptive file name for this part. |
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)
Set the Part content as text. |
void |
setText(String text,
String charset)
|
void |
setText(String text,
String charset,
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(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 messagepublic 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 streampublic MimeMessage(MimeMessage message) throws MessagingException
message
- the message to copy
MessagingException
- 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, 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 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 message
MessagingException
- if there is a problem reading or parsing the streamMethod 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 streampublic Address[] getFrom() throws MessagingException
getFrom
in class Message
MessagingException
public void setFrom(Address address) throws MessagingException
setFrom
in class Message
address
- The new "From" target.
MessagingException
public void setFrom() throws MessagingException
InternetAddress.getLocalAddress(javax.mail.Session)
.
setFrom
in class Message
MessagingException
- if there was a problem setting the headerpublic void addFrom(Address[] addresses) throws MessagingException
addFrom
in class Message
addresses
- The list to add.
MessagingException
public Address getSender() throws MessagingException
MessagingException
- if there was a problem parsing the headerpublic void setSender(Address address) throws MessagingException
address
- the new Sender address
MessagingException
- if there was a problem setting the headerpublic Address[] getRecipients(Message.RecipientType type) throws MessagingException
getRecipients
in class Message
type
- The message RecipientType identifier.
MessagingException
Message.RecipientType
public Address[] getAllRecipients() throws MessagingException
getAllRecipients
in class Message
MessagingException
public void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
setRecipients
in class Message
type
- 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 Message
type
- 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 Message
MessagingException
public void setReplyTo(Address[] address) throws MessagingException
setReplyTo
in class Message
address
- The new field value.
MessagingException
public String getSubject() throws MessagingException
getSubject
in class Message
MessagingException
public void setSubject(String subject) throws MessagingException
setSubject
in class Message
subject
- The new subject value.
MessagingException
public void setSubject(String subject, String charset) throws MessagingException
MessagingException
public Date getSentDate() throws MessagingException
getSentDate
in class Message
MessagingException
public void setSentDate(Date sent) throws MessagingException
setSentDate
in class Message
sent
- The new sent date value.
MessagingException
public Date getReceivedDate() throws MessagingException
getReceivedDate
in class Message
MessagingException
public int getSize() throws MessagingException
getSize
in interface Part
MessagingException
public int getLineCount() throws MessagingException
getLineCount
in interface Part
MessagingException
public String getContentType() throws MessagingException
getContentType
in interface Part
MessagingException
public boolean isMimeType(String type) throws MessagingException
isMimeType
in interface Part
type
- The tested type name.
MessagingException
public String getDisposition() throws MessagingException
getDisposition
in interface Part
MessagingException
public void setDisposition(String disposition) throws MessagingException
setDisposition
in interface Part
disposition
- The new disposition value.
MessagingException
public String getEncoding() throws MessagingException
getEncoding
in interface MimePart
MessagingException
public String getContentID() throws MessagingException
getContentID
in interface MimePart
MessagingException
public void setContentID(String cid) throws MessagingException
MessagingException
public String getContentMD5() throws MessagingException
getContentMD5
in interface MimePart
MessagingException
public void setContentMD5(String md5) throws MessagingException
setContentMD5
in interface MimePart
MessagingException
public String getDescription() throws MessagingException
Part
getDescription
in interface Part
MessagingException
public void setDescription(String description) throws MessagingException
Part
setDescription
in interface Part
description
- The new description.
MessagingException
public void setDescription(String description, String charset) throws MessagingException
MessagingException
public String[] getContentLanguage() throws MessagingException
getContentLanguage
in interface MimePart
MessagingException
public void setContentLanguage(String[] languages) throws MessagingException
setContentLanguage
in interface MimePart
MessagingException
public String getMessageID() throws MessagingException
MessagingException
public String getFileName() throws MessagingException
Part
getFileName
in interface Part
MessagingException
public void setFileName(String name) throws MessagingException
Part
setFileName
in interface Part
name
- The new name value.
MessagingException
public InputStream getInputStream() throws MessagingException, IOException
Part
getInputStream
in interface Part
MessagingException
IOException
protected InputStream getContentStream() throws MessagingException
MessagingException
public InputStream getRawInputStream() throws MessagingException
MessagingException
public DataHandler getDataHandler() throws MessagingException
Part
getDataHandler
in interface Part
MessagingException
public Object getContent() throws MessagingException, IOException
Part
getContent
in interface Part
MessagingException
IOException
public void setDataHandler(DataHandler handler) throws MessagingException
Part
setDataHandler
in interface Part
handler
- The DataHandler instance.
MessagingException
public void setContent(Object content, String type) throws MessagingException
Part
setContent
in interface Part
content
- The content object.type
- The MIME type for the inserted content Object.
MessagingException
public void setText(String text) throws MessagingException
Part
setText
in interface MimePart
setText
in interface Part
text
- The new text content, as a String object.
MessagingException
public void setText(String text, String charset) throws MessagingException
setText
in interface MimePart
MessagingException
public void setText(String text, String charset, String subtype) throws MessagingException
setText
in interface MimePart
MessagingException
public void setContent(Multipart part) throws MessagingException
setContent
in interface Part
MessagingException
public Message reply(boolean replyToAll) throws MessagingException
Message
Message.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 Message
replyToAll
- if true, indciates the message should be addressed to all recipients not just the sender
MessagingException
- if there was a problem accessing the Storepublic void writeTo(OutputStream out) throws MessagingException, IOException
writeTo
in interface Part
out
- 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 Part
name
- The target name.
MessagingException
public String getHeader(String name, String delimiter) throws MessagingException
getHeader
in interface MimePart
name
- 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 Part
name
- 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 Part
name
- The name of the target header.value
- The removed header.
MessagingException
public void removeHeader(String name) throws MessagingException
removeHeader
in interface Part
name
- The name of the removed header.
MessagingException
public Enumeration getAllHeaders() throws MessagingException
getAllHeaders
in interface Part
MessagingException
public Enumeration getMatchingHeaders(String[] names) throws MessagingException
Part
getMatchingHeaders
in interface Part
names
- An array of names of the desired headers.
MessagingException
public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException
Part
getNonMatchingHeaders
in interface Part
names
- An array of String header names that will be excluded from the return
Enumeration set.
MessagingException
public void addHeaderLine(String line) throws MessagingException
addHeaderLine
in interface MimePart
MessagingException
public Enumeration getAllHeaderLines() throws MessagingException
getAllHeaderLines
in interface MimePart
MessagingException
public Enumeration getMatchingHeaderLines(String[] names) throws MessagingException
getMatchingHeaderLines
in interface MimePart
MessagingException
public Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException
getNonMatchingHeaderLines
in interface MimePart
MessagingException
public Flags getFlags() throws MessagingException
getFlags
in class Message
MessagingException
- if there was a problem accessing the Storepublic boolean isSet(Flags.Flag flag) throws MessagingException
getFlags()
.
isSet
in class Message
flag
- the flags to check for
MessagingException
- if there was a problem accessing the Storepublic void setFlags(Flags flag, boolean set) throws MessagingException
setFlags
in class Message
flags
- 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 Message
MessagingException
protected void updateHeaders() throws MessagingException
MessagingException
protected InternetHeaders createInternetHeaders(InputStream in) throws MessagingException
in
- The header source.
MessagingException
protected void updateMessageID() throws MessagingException
MessagingException
protected MimeMessage createMimeMessage(Session session) throws MessagingException
session
- The session associated with this message.
MessagingException
- if the MimeMessage could not be created
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |