All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.network.mail.base.MimeMessage

java.lang.Object
   |
   +----com.ibm.network.mail.base.MimeMessage

public class MimeMessage
extends Object
implements MimePart
This class represents a MIME style e-mail message. It implements the MimePart interface. It contains a Header to store the toplevel RFC 822 headers of a message.

Clients wanting to create new MIME style messages will instantiate an empty MimeMessage object and then fill it with appropriate attributes and content.
For example,

       MimeMessage msg = new MimeMessage();
       
String fileName = "mail.txt"; MimeBodyPart part = new MimeBodyPart(new FileInputStream(fileName)); part.addHeader(Constants.contentType, "text/plain"); part.setEncoding(MimePart.BASE64); part.setDisposition(MimePart.INLINE);
msg.setContent(part, ""); msg.addHeader("Subject", "Test Mail");
InternetAddress[] to = new InternetAddress[1]; to[0] = new InternetAddress("Abdul Majeed Ghadialy<majeed@pobox.com>");
InternetAddress[] cc = new InternetAddress[1]; cc[0] = new InternetAddress("Mohit M. Sant<mohitsant@hotmail.com>");
InternetAddress[] bcc = new InternetAddress[1]; bcc[0] = new InternetAddress("Abdul Majeed Ghadialy<majeed@vnet.ibm.com>");
msg.addRecipients(MimeMessage.TO, to); msg.addRecipients(MimeMessage.CC, cc); msg.addRecipients(MimeMessage.BCC, bcc);

Author:
Abdul Majeed Ghadialy, Mohit M. Sant
See Also:
MimePart, MimeBodyPart, MimeMultipart, Header, Flags, InternetAddress

Variable Index

 o BCC
 o CC
 o TO

Constructor Index

 o MimeMessage()
Constructor for MimeMessage.

Method Index

 o addHeader(String, String)
Adds a field to the header of the message.
 o addRecipients(int, InternetAddress[])
Adds the specified recipients.
 o getContent()
Returns the content of this message.
 o getContentType()
Returns the MIME data type of the content of this message.
 o getDisposition()
Returns the Content-Disposition of this part.
 o getEncoding()
Returns the Content-Transfer-Encoding of this part.
 o getFileName()
Returns the file name of this part, if any.
 o getFlags()
Returbs the Flags object associated with this message.
 o getHeader()
Returns the Header of this message.
 o getHeader(String)
Returns the header field value for the specified header field key.
 o getInputStream()
Returns an InputStream connected to the content of this message..
 o getRecipients()
Returns a list of all the recipients of this message.
 o putByteStream(OutputStream)
Writes the header of this message and encoded data of the content to the os.
 o setContent(Object, String)
Sets the content and the MIME data type of this part.
 o setDisposition(int)
Sets the Content-Disposition of this part.
 o setEncoding(int)
Sets the Content-Transfer-Encoding of this part.
 o setFileName(String)
Sets the file name of this part.
 o setFlags(Flags)
Sets the Flags of this message.
 o setHeader(String, String)
Adds a new field to the Header of this part.

Variables

 o TO
 public static final int TO
 o CC
 public static final int CC
 o BCC
 public static final int BCC

Constructors

 o MimeMessage
 public MimeMessage()
Constructor for MimeMessage. Creates an empty MimeMessage with the default message header fields.

Methods

 o addHeader
 public void addHeader(String name,
                       String value)
Adds a field to the header of the message. If a field of this name is already present, the old value will be overwritten by the value.

Parameters:
name - header field key.
value - header field value.
 o addRecipients
 public void addRecipients(int type,
                           InternetAddress recipients[])
Adds the specified recipients.

Parameters:
type - recipient type.
recipients - recipient addresses.
See Also:
TO, CC, BCC
 o getContent
 public Object getContent()
Returns the content of this message. This content may be a MimeBodyPart in case the message consists of a single body part or it can be MimeMultipart if it consists of multiple body parts.

Returns:
content of this message.
 o getContentType
 public String getContentType()
Returns the MIME data type of the content of this message.

Returns:
the MIME data type of the content of this message.
 o getDisposition
 public int getDisposition()
Returns the Content-Disposition of this part. The disposition describes how the part should be presented to the user.

Returns:
the Content-Disposition of this part.
 o getEncoding
 public int getEncoding()
Returns the Content-Transfer-Encoding of this part.

Returns:
the Content-Transfer-Encoding of this part.
 o getFileName
 public String getFileName()
Returns the file name of this part, if any.

Returns:
the file name of this part, if any.
 o getFlags
 public Flags getFlags()
Returbs the Flags object associated with this message.

Returns:
the Flags object associated with this message.
 o getHeader
 public Header getHeader()
Returns the Header of this message.

Returns:
the Header of this message.
 o getHeader
 public String getHeader(String name)
Returns the header field value for the specified header field key.

Parameters:
name - header field key.
Returns:
header field value.
 o getInputStream
 public InputStream getInputStream()
Returns an InputStream connected to the content of this message..

Returns:
InputStream connected to the content of this message.
 o getRecipients
 public InternetAddress[] getRecipients()
Returns a list of all the recipients of this message. This list consists of all the recipients mentioned in "To", "Cc" and "Bcc".

Returns:
list of all the recipients of this message
 o putByteStream
 public void putByteStream(OutputStream os) throws IOException
Writes the header of this message and encoded data of the content to the os.

Parameters:
os - OutputStream to write header and content
Throws: IOException
in case an IO error is encountered
See Also:
putByteStream, putByteStream
 o setContent
 public void setContent(Object content,
                        String type)
Sets the content and the MIME data type of this part.

Parameters:
content - content to be set in this part.
type - MIME data type.
 o setDisposition
 public void setDisposition(int disp)
Sets the Content-Disposition of this part.

Parameters:
disp - Content-Disposition.
 o setEncoding
 public void setEncoding(int encoding)
Sets the Content-Transfer-Encoding of this part.

Parameters:
encoding - Content-Transfer-Encoding.
 o setFileName
 public void setFileName(String fileName)
Sets the file name of this part.

Parameters:
fileName - name of the file.
 o setFlags
 public void setFlags(Flags flags)
Sets the Flags of this message.

Parameters:
flags - Flags object to be set in this message.
 o setHeader
 public void setHeader(String name,
                       String value)
Adds a new field to the Header of this part.

Parameters:
name - header field key
value - header field value
See Also:
addField

All Packages  Class Hierarchy  This Package  Previous  Next  Index