Name
Part
Synopsis
The Part
interface provides the core functionality for JavaMail messages. It is used by both Message
objects and BodyPart
objects to manipulate message attributes and content. When implemented by a
Message
object, Part
provides overall information about the entire message, including content type and
message headers. In this case, the content of the Part
can be of one type (such as text) or a Multipart
object
containing a set of BodyPart
objects. Each BodyPart
also implements Part
, and contains a component of a
multipart message (body text, HTML text, file attachments and so on). The attributes of each BodyPart
object define the nature and disposition of that particular part. Part
models a MIME Entity (see RFC-2045
for more information).
The Part
interface provides set and get methods for commonly used message attributes: content, filename,
size, and disposition. Arbitrary message headers can be set using the setHeader()
and addHeader()
methods,
or by using the additional set and get methods provided by the various Part
subclasses.
The content of a Part
can be set in a variety of ways. The simplest is to call setText()
, which allows String
content with a MIME type of “text/plain.” Content can also be set via the various setContent()
methods,
which accept Java objects and MIME types, as well as DataHandler
objects from the JavaMail Activation
Framework.
public interface Part { // Public Constants public static final String ATTACHMENT; // ="attachment” public static ...
Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.