Sending Email Using JAVA
Sending Email Using JAVA
MIME's use, however, has grown beyond describing the content of e-mail to
describing content type in general, including for the web (see Internet media type).
Virtually all human-written Internet e-mail and a fairly large proportion of automated
e-mail is transmitted via SMTP in MIME format. Internet e-mail is so closely
associated with the SMTP and MIME standards that it is sometimes called
SMTP/MIME e-mail.
javax.mail
public interface Part
The Part interface is the common base interface for Messages and BodyParts.
Attributes:
The JavaMail API defines a set of standard Part attributes that are considered to be
common to most existing Mail systems. These attributes have their own settor and
gettor methods. Mail systems may support other Part attributes as well, these are
represented as name-value pairs where both the name and value are Strings.
Content:
The data type of the "content" is returned by the getContentType() method. The
MIME typing system is used to name data types.
This class represents a MIME body part. It implements the BodyPart abstract class
and the MimePart interface. MimeBodyParts are contained in MimeMultipart
objects.
MimeBodyPart uses the InternetHeaders class to parse and store the headers of that
body part.
This class models a Part that is contained within a Multipart. This is an abstract class.
Subclasses provide actual implementations.
BodyPart implements the Part interface. Thus, it contains a set of attributes and a
"content".
public abstract class Multipart
extends Object
Multipart is a container that holds multiple body parts. Multipart provides methods to
retrieve and set its subparts.
Multipart also acts as the base class for the content object returned by most Multipart
DataContentHandlers. For example, invoking getContent() on a DataHandler whose
source is a "multipart/signed" data source may return an appropriate subclass of
Multipart.
This class represents a MIME style email message. It implements the Message
abstract class and the MimePart interface.
Clients wanting to create new MIME style messages will instantiate an empty
MimeMessage object and then fill it with appropriate attributes and content.
Service providers that implement MIME compliant backend stores may want to
subclass MimeMessage and override certain methods to provide specific
implementations. The simplest case is probably a provider that generates a MIME
style input stream and leaves the parsing of the stream to this class.
MimeMessage uses the InternetHeaders class to parse and store the top level RFC
822 headers of a message.
This inner class defines the types of recipients allowed by the Message class. The
currently defined types are TO, CC and BCC. Note that this class only has a protected
constructor, thereby restricting new Recipient types to either this class or subclasses.
This effectively implements an enumeration of the allowed Recipient types. The
following code sample shows how to use this class to obtain the "TO" recipients from
a message.