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
-
BCC
-
-
CC
-
-
TO
-
-
MimeMessage()
- Constructor for
MimeMessage
.
-
addHeader(String, String)
- Adds a field to the header of the message.
-
addRecipients(int, InternetAddress[])
- Adds the specified recipients.
-
getContent()
- Returns the content of this message.
-
getContentType()
- Returns the MIME data type of the content of this message.
-
getDisposition()
- Returns the Content-Disposition of this part.
-
getEncoding()
- Returns the Content-Transfer-Encoding of this part.
-
getFileName()
- Returns the file name of this part, if any.
-
getFlags()
- Returbs the
Flags
object associated with this message.
-
getHeader()
- Returns the
Header
of this message.
-
getHeader(String)
- Returns the header field value for the specified header field key.
-
getInputStream()
- Returns an
InputStream
connected to the content of this
message..
-
getRecipients()
- Returns a list of all the recipients of this message.
-
putByteStream(OutputStream)
- Writes the header of this message and encoded data of the content to the
os
.
-
setContent(Object, String)
- Sets the content and the MIME data type of this part.
-
setDisposition(int)
- Sets the Content-Disposition of this part.
-
setEncoding(int)
- Sets the Content-Transfer-Encoding of this part.
-
setFileName(String)
- Sets the file name of this part.
-
setFlags(Flags)
- Sets the
Flags
of this message.
-
setHeader(String, String)
- Adds a new field to the
Header
of this part.
TO
public static final int TO
CC
public static final int CC
BCC
public static final int BCC
MimeMessage
public MimeMessage()
- Constructor for
MimeMessage
.
Creates an empty MimeMessage
with the default message header
fields.
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.
addRecipients
public void addRecipients(int type,
InternetAddress recipients[])
- Adds the specified recipients.
- Parameters:
- type - recipient type.
- recipients - recipient addresses.
- See Also:
- TO, CC, BCC
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.
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.
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.
getEncoding
public int getEncoding()
- Returns the Content-Transfer-Encoding of this part.
- Returns:
- the Content-Transfer-Encoding of this part.
getFileName
public String getFileName()
- Returns the file name of this part, if any.
- Returns:
- the file name of this part, if any.
getFlags
public Flags getFlags()
- Returbs the
Flags
object associated with this message.
- Returns:
- the
Flags
object associated with this message.
getHeader
public Header getHeader()
- Returns the
Header
of this message.
- Returns:
- the
Header
of this message.
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.
getInputStream
public InputStream getInputStream()
- Returns an
InputStream
connected to the content of this
message..
- Returns:
-
InputStream
connected to the content of this
message.
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
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
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.
setDisposition
public void setDisposition(int disp)
- Sets the Content-Disposition of this part.
- Parameters:
- disp - Content-Disposition.
setEncoding
public void setEncoding(int encoding)
- Sets the Content-Transfer-Encoding of this part.
- Parameters:
- encoding - Content-Transfer-Encoding.
setFileName
public void setFileName(String fileName)
- Sets the file name of this part.
- Parameters:
- fileName - name of the file.
setFlags
public void setFlags(Flags flags)
- Sets the
Flags
of this message.
- Parameters:
- flags -
Flags
object to be set in this message.
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