public class Part
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTACHMENT |
static java.lang.String |
BINARY |
protected java.lang.Object |
content |
protected DataContentHandler |
contentHandler |
java.lang.String |
disposition
Defines if this part's content should be inlined in the body of the message, or attached as a file.
Its value MUST be set to either INLINE (default value) or ATTACHMENT, using the constants defined by the class Part. |
java.lang.String |
fileName
File name of the attachment represented by this part (if any).
If assigned with a non-null value, the field disposition value is ignored and the part treated as ATTACHMENT. |
protected totalcross.net.mail.PartHeaders |
headers |
static java.lang.String |
HTML |
static java.lang.String |
INLINE |
protected java.lang.String |
mimeType |
static java.lang.String |
PLAIN |
Constructor and Description |
---|
Part() |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Add this value to the existing values for this header name.
|
java.lang.Object |
getContent()
Returns the content of this part.
|
java.lang.String |
getContentType()
Returns the Content-Type of the content of this part.
|
void |
setContent(Multipart multipart)
This method sets the given Multipart object as this part's content.
|
void |
setContent(java.lang.Object content)
A convenience method for setting this part's content based on the type of the passed object.
If the given object type is Multipart, it's MIME type is set to "multipart/mixed". If the given object type is String, it's MIME type is set to "text/plain". Otherwise, the given object will be handled as "application/octet-stream" by the BinaryContentHandler. |
void |
setContent(java.lang.Object content,
java.lang.String mimeType)
A convenience method for setting this part's content.
Note that a DataContentHandler class for the specified type should be available, otherwise the content will be handled by the BinaryContentHandler, which writes the content as a base 64 encoded String. |
void |
setText(java.lang.String text)
A convenience method that sets the given String as this part's content with a MIME type of "text/plain".
|
void |
writeTo(Stream stream)
Writes this part to the given Stream.
|
public static final java.lang.String INLINE
public static final java.lang.String ATTACHMENT
public static final java.lang.String PLAIN
public static final java.lang.String HTML
public static final java.lang.String BINARY
public java.lang.String disposition
public java.lang.String fileName
protected java.lang.Object content
protected java.lang.String mimeType
protected DataContentHandler contentHandler
protected totalcross.net.mail.PartHeaders headers
public void addHeader(java.lang.String name, java.lang.String value)
name
- the name of this headervalue
- the value for this headerpublic java.lang.String getContentType()
public void setContent(java.lang.Object content, java.lang.String mimeType)
content
- this part's contentmimeType
- content's MIME typejava.lang.IllegalArgumentException
- if the given content is a Part objectBinaryContentHandler
public void setContent(Multipart multipart)
multipart
- the multipart object that is the part's contentpublic void setContent(java.lang.Object content)
content
- this part's contentjava.lang.IllegalArgumentException
- if the given content is a Part objectpublic void setText(java.lang.String text)
text
- the text that is this part's content.public void writeTo(Stream stream) throws IOException, MessagingException
stream
- the output stream that will receive this part's encoded representationIOException
- if an error occurs writing to the streamMessagingException
- if an error occurs fetching the data to be writtenpublic java.lang.Object getContent()