Working with a MIME entity in Java™ classes
The MIMEEntity object is used to read items of type MIME (Multipurpose Internet Mail Extensions). MIME defines techniques for handling 8-bit data, character sets, and a variety of content types. MIME also allows for structured messages, where a message can have multiple parts and relations between the parts.
A typical example is an Internet mail message routed to a mail file without conversion to rich text.
The MIME parts of a document are items of type MIME_PART. In Internet mail messages they are typically named "Body." Programmatically you can access these items as Item, RichTextItem, or MIMEEntity objects.
To access the MIME content of a Document:
- First call Session.setConvertMIME(false) to override normal conversion of MIME items to rich text.
- Then call Document.getMIMEEntity.
- Or call Document.getFirstItem followed by Item.getMIMEEntity.
- To create an item in MIME format, call Document.createMIMEEntity.
- To close MIME processing so you can work on items directly, call Document.closeMIMEEntities.
- Before exiting your code, call Session.setConvertMIME(true) (or restore the original setting).
You access the MIME entity properties through the following methods:
- getBoundaryEnd returns a String value containing the boundary that follows the last child entity.
- getBoundaryStart returns a String value containing the boundary that precedes a child entity.
- getCharset returns a String value containing the content character set of a MIME entity.
- getContentAsText returns a String value containing the text content of a MIME entity.
- getContentSubType returns a String value containing the sub-type of the content type of a MIME entity.
- getContentType returns a String value containing the content type of a MIME entity.
- getEncoding returns the current encoding for the non-header content of a MIME entity.
- getHeaderObjects returns a vector of MIMEHeader objects containing the headers for a MIME entity.
- getHeaders returns a String value containing the headers; getSomeHeaders returns specified headers.
- getPreamble returns a String value containing the preamble of a multipart entry; setPreamble writes a String value to the preamble.
The following methods access the content of a MIME entity:
- decodeContent
- encodeContent
- getContentAsBytes
- getContentAsText
- getEntityAsText
- setContentFromBytes
- setContentFromText
The following methods manipulate multipart MIME entities:
- createChildEntity
- createParentEntity
- getFirstChildEntity
- getNextEntity
- getNextSibling
- getParentEntity
- getPrevEntity
- getPrevSibling
The remove method removes an entity.
The createHeader and getNthHeader methods access MIME headers as MIMEHeader objects (as well as the HeaderObjects property).
The MIMEHeader class has a getHeaderName method, a remove method, and the following methods for accessing header content:
- addValText
- getHeaderVal
- getHeaderValAndParams
- getParamVal
- setHeaderVal
- setHeaderValAndParams
- setParamVal