public class MimeMessage
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
MimeMessage()
Constructs a new MimeMessage.
|
MimeMessage(byte[] message)
Constructs a
MimeMessage from existing content. |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(MimeHeader header)
Adds MIME header to this
MimeMessage . |
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds MIME header to this
MimeMessage . |
void |
addPart(MimeMessage message)
Adds part to multipart
MimeMessage . |
void |
addReplaceHeader(MimeHeader header)
Adds MIME header to this
MimeMessage , replacing existing header if found. |
void |
addReplaceHeader(java.lang.String name,
java.lang.String value)
Adds MIME header to this
MimeMessage , replacing existing header if found. |
java.lang.String |
getBody()
Gets decoded message body using character encoding specified in charset
attribute of Content-Type message header.
|
java.io.File |
getBodyAsFile()
Get the file body.
|
byte[] |
getBodyData()
Gets decoded message body as bytes.
|
java.lang.String |
getBoundary()
Gets boundary used in this
MimeMessage . |
java.lang.String |
getContentTransferEncoding()
Gets the value of the Content-Transfer-Encoding header for this
MimeMessage . |
java.lang.String |
getContentType()
Gets the content-type of this
MimeMessage . |
MimeHeader |
getHeader(java.lang.String name)
Returns named header specified by
name . |
java.util.Enumeration |
getHeaders()
Gets all mime headers for this
MimeMessage . |
java.util.Enumeration |
getHeaders(java.lang.String name)
Gets all MIME headers for this
MimeMessage with specified name. |
java.lang.String |
getHeaderValue(java.lang.String name)
Gets value for header specified by
name
If more than one header with specified name exists for this MimeMessage then
the value of the last header added to this MimeMessage with specified name
will be returned. |
byte[] |
getMessage()
Gets contents of this
MimeMessage . |
MimeMessage |
getPart(int index)
Gets specified part from this
MimeMessage . |
java.util.Enumeration |
getParts()
Gets parts of this
MimeMessage . |
byte[] |
getRawBodyData()
Gets message body as bytes.
|
void |
removeHeader(java.lang.String name)
Removes specified header from this
MimeMessage . |
void |
removePart(int index)
Removes specified
index from parts array. |
void |
removeParts()
Removes all parts from this message.
|
void |
setBody(byte[] contents)
Sets body of this
MimeMessage . |
void |
setBody(java.io.File file)
Sets body of this
MimeMessage . |
void |
setBody(java.lang.String body)
Sets body of this
MimeMessage . |
void |
setBody(java.lang.String body,
java.lang.String characterSet)
Sets body of this
MimeMessage and sets the charset
attribute of Content-Type header to provided character set. |
void |
setBodyAsFile(java.io.File body) |
void |
setContentType(java.lang.String contentType)
Sets the content-type of this
MimeMessage . |
public MimeMessage()
public MimeMessage(byte[] message) throws MimeException
MimeMessage
from existing content.message
- the contents of mime messageMimeException
- a Mime parsing error occurspublic byte[] getMessage() throws MimeException
MimeMessage
. Contents include all
MIME message headers, body and any parts.MimeException
- if a MIME related parsing error occurspublic void setContentType(java.lang.String contentType) throws MimeException
MimeMessage
.contentType
- the content-typeMimeException
- if a MIME related parsing error occurspublic java.lang.String getContentType()
MimeMessage
.public java.lang.String getContentTransferEncoding()
MimeMessage
. The Content-Transfer-Encoding header
indicates the encoding method used for the message body. Typical values
are BASE64, UUENCODE, 7BIT, 8BIT and QUOTED-PRINTABLEpublic void setBodyAsFile(java.io.File body)
public java.io.File getBodyAsFile()
public void setBody(java.lang.String body)
MimeMessage
. Default system character
encoding is used to convert the body to bytes.body
- the body contentspublic void setBody(java.lang.String body, java.lang.String characterSet) throws MimeException
MimeMessage
and sets the charset
attribute of Content-Type header to provided character set. If
Content-Type header is not found then a new Content-Type header will be
created with a value of text/plain.body
- the body contentscharacterSet
- the character set the body it to be set with.MimeException
- if a MIME related parsing error occurspublic void setBody(byte[] contents)
MimeMessage
.contents
- the body contentspublic void setBody(java.io.File file) throws java.io.IOException
MimeMessage
.file
- the body contentsjava.io.IOException
- if an I/O error occurs reading filepublic java.lang.String getHeaderValue(java.lang.String name)
name
If more than one header with specified name
exists for this MimeMessage
then
the value of the last header added to this MimeMessage
with specified name
will be returned. To get all header see the getHeaders method.name
- the name of the header to retrivegetHeaders()
public MimeHeader getHeader(java.lang.String name)
name
.
If more than one header with specified name
exists for this MimeMessage
then
the last header added to this MimeMessage
with specified name
will be returned.
To get all header see the getHeaders method.name
- the name of the header to retrieveMimeHeader
or null
if header is not
presentgetHeaders()
public java.lang.String getBody() throws MimeException
MimeException
- if a MIME related parsing error occurspublic byte[] getBodyData() throws MimeException
MimeException
- if a MIME related parsing error occurspublic byte[] getRawBodyData()
public java.lang.String getBoundary() throws MimeException
MimeMessage
.MimeException
- if a MIME related parsing error occurspublic void addPart(MimeMessage message) throws MimeException
MimeMessage
. If not previously set
boundary string is generated. This method also sets Content-Type field
for this MimeMessage
to multipart/mixed to reflect
multipart nature of the message.message
- the MimeMessage
to add to this
MimeMessage
MimeException
- if a MIME related parsing error occurspublic java.util.Enumeration getParts()
MimeMessage
. Returns an Enumeration of
MimeMessage
.public void removePart(int index)
index
from parts array.index
- the index of part to removepublic void removeParts()
public void addHeader(MimeHeader header)
MimeMessage
.header
- a MimeHeader
public void addReplaceHeader(MimeHeader header)
MimeMessage
, replacing existing header if found.header
- a MimeHeader
public void addReplaceHeader(java.lang.String name, java.lang.String value) throws MimeException
MimeMessage
, replacing existing header if found.name
- the header namevalue
- the header valueMimeException
- if a MIME related parsing error occurspublic void addHeader(java.lang.String name, java.lang.String value) throws MimeException
MimeMessage
.name
- the header namevalue
- the header valueMimeException
- if a MIME related parsing error occurspublic void removeHeader(java.lang.String name)
MimeMessage
.name
- the name of the header to removepublic java.util.Enumeration getHeaders()
MimeMessage
. Returns an
Enumeration of MimeHeader
.public java.util.Enumeration getHeaders(java.lang.String name)
MimeMessage
with specified name. Returns an
Enumeration of MimeHeader
.name
- the header namepublic MimeMessage getPart(int index)
MimeMessage
.index
- the index of partMimeMessage
or null
if not presentCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved