public class EmailMessage extends MimeMessage
EmailMessage message = new EmailMessage(); message.setTo("jsmith@myserver.com"); message.setFrom("rjones@myserver.com"); message.setSubject("Meeting at 8"); message.setBody("See you then");
Constructor and Description |
---|
EmailMessage()
Constructs an
EmailMessage instance. |
EmailMessage(byte[] contents)
Contructs and EmailMessage instance from contents of
contents . |
EmailMessage(java.lang.String to,
java.lang.String from)
Constructs an
EmailMessage instance defining to and from addresses. |
EmailMessage(java.lang.String to,
java.lang.String from,
java.lang.String subject,
java.lang.String body)
Constructs an
EmailMessage instance defining to and from addresses
and subject and body of email. |
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(Attachment attachment)
Adds attachment to this email message.
|
void |
addAttachment(Attachment attachment,
boolean wrap)
Adds attachment to this email message.
|
java.util.Enumeration |
getAttachments()
Gets all message attachments from this email message.
|
java.lang.String |
getBcc()
Gets Bcc address of message.
|
java.lang.String |
getBody()
Gets body of message.
|
java.lang.String |
getCc()
Gets Cc address of message.
|
java.lang.String |
getContentType()
Gets Content-Type header of email message.
|
java.lang.String |
getDate()
Gets Date of message.
|
java.lang.String |
getFrom()
Gets From address of message.
|
byte[] |
getMessage()
Gets contents of this
EmailMessage . |
int |
getPriority()
Gets priority of message when displayed in recipients email client.
|
java.lang.String |
getReplyTo()
Gets reply-to address of message.
|
java.lang.String |
getSubject()
Gets Subject of message.
|
java.lang.String |
getTo()
Gets To address of message.
|
void |
setBcc(java.lang.String bcc)
Sets receipient blind-carbon-copy email address.
|
void |
setCc(java.lang.String cc)
Sets receipient carbon-copy email address.
|
void |
setCc(java.lang.String cc,
java.lang.String characterEncoding)
Sets receipient carbon-copy email address.
|
void |
setContentType(java.lang.String contentType)
Sets Content-Type header of email message.
|
void |
setContentType(java.lang.String contentType,
java.lang.String characterSet)
Sets Content-Type header of email message.
|
void |
setFrom(java.lang.String from)
Sets from email address.
|
void |
setFrom(java.lang.String from,
java.lang.String characterEncoding)
Sets from email address using defined character encoding.
|
void |
setPriority(int priority)
Sets priority of message when displayed in recipients email client.
|
void |
setReplyTo(java.lang.String replyto)
Sets message Reply-To address.
|
void |
setReplyTo(java.lang.String replyto,
java.lang.String characterEncoding)
Sets message Reply-To address.
|
void |
setSubject(java.lang.String subject)
Sets message subject.
|
void |
setSubject(java.lang.String subject,
java.lang.String characterEncoding)
Sets message subject.
|
void |
setTo(java.lang.String to)
Sets receipient to email address.
|
void |
setTo(java.lang.String to,
java.lang.String characterEncoding)
Sets receipient to email address.
|
addHeader, addHeader, addPart, addReplaceHeader, addReplaceHeader, getBodyAsFile, getBodyData, getBoundary, getContentTransferEncoding, getHeader, getHeaders, getHeaders, getHeaderValue, getPart, getParts, getRawBodyData, removeHeader, removePart, removeParts, setBody, setBody, setBody, setBody, setBodyAsFile
public EmailMessage() throws MimeException
EmailMessage
instance.
Default headers Date, MIME-Version, Message-ID, Content-Transfer-Encoding and
Content-Type are added automaticallyMimeException
- if a MIME related error occurspublic EmailMessage(java.lang.String to, java.lang.String from) throws MimeException
EmailMessage
instance defining to and from addresses.
Default headers Date, MIME-Version, Message-ID, Content-Transfer-Encoding and
Content-Type are added automatically.to
- the to addressfrom
- the from addressMimeException
- if a MIME related error occurspublic EmailMessage(java.lang.String to, java.lang.String from, java.lang.String subject, java.lang.String body) throws MimeException
EmailMessage
instance defining to and from addresses
and subject and body of email.
Default headers Date, MIME-Version, Message-ID, Content-Transfer-Encoding and
Content-Type are added automatically.to
- the to addressfrom
- the from addresssubject
- the subject of the emailbody
- the body of the emailMimeException
- if a MIME related error occurspublic EmailMessage(byte[] contents) throws MimeException
contents
.contents
- a byte[]
containing contents of messageMimeException
- if a error occurs during message parsepublic byte[] getMessage() throws MimeException
EmailMessage
. Contents include all
MIME message headers, body and any parts.getMessage
in class MimeMessage
MimeException
- if a MIME related parsing error occurspublic void setContentType(java.lang.String contentType, java.lang.String characterSet) throws MimeException
EmailMessage
instance.
are text/plain and us-ascii respectivelycontentType
- the content type of email messagecharacterSet
- the character set used for contentMimeException
- if a MIME related error occurspublic void setContentType(java.lang.String contentType) throws MimeException
EmailMessage
instance.
are text/plain and us-ascii respectivelysetContentType
in class MimeMessage
contentType
- the content type of email messageMimeException
- if a MIME related error occurspublic java.lang.String getContentType()
getContentType
in class MimeMessage
public void addAttachment(Attachment attachment) throws MimeException
attachment
- the Attachment
to addMimeException
- if a MIME related error occurspublic void addAttachment(Attachment attachment, boolean wrap) throws MimeException
attachment
- the attachment to addwrap
- true if to wrap existing body in a new part and add part to message, false to leave existing body as isMimeException
- if a MIME related error occurspublic java.util.Enumeration getAttachments() throws MimeException
Enumeration
of Attachment
MimeException
- if error occurs in decoding attachmentspublic void setFrom(java.lang.String from) throws MimeException
from
- the from email addressMimeException
- if a MIME related error occurspublic void setFrom(java.lang.String from, java.lang.String characterEncoding) throws MimeException
from
- the from email addresscharacterEncoding
- the character encoding usedMimeException
- thrown if an error occurs while encoding From headerMimeException
public void setTo(java.lang.String to) throws MimeException
to
- the recipient to email addressMimeException
- if a MIME related error occurspublic void setTo(java.lang.String to, java.lang.String characterEncoding) throws MimeException
user@domain.com, user2@domain.com, user3@domain.comTo address is encoded according to RFC 2047. This method should be used in cases where the address contains data other than US-ASCII characters.
to
- the to email addresscharacterEncoding
- the character encoding usedMimeException
- thrown if an error occurs while encoding To headerMimeException
public void setCc(java.lang.String cc) throws MimeException
user@domain.com, user2@domain.com, user3@domain.com
cc
- the recipient carbon-copy email addressMimeException
- if a MIME related error occurspublic void setCc(java.lang.String cc, java.lang.String characterEncoding) throws MimeException
user@domain.com, user2@domain.com, user3@domain.comCc address is encoded according to RFC 2047. This method should be used in cases where the address contains data other than US-ASCII characters.
cc
- the recipient carbon-copy email addresscharacterEncoding
- the character encoding usedMimeException
- thrown if an error occurs while encoding Cc headerMimeException
public void setBcc(java.lang.String bcc) throws MimeException
user@domain.com,user2@domain.com,user3@domain.com
bcc
- the recipient blind-carbon-copy email addressMimeException
- if a MIME related error occurspublic void setReplyTo(java.lang.String replyto, java.lang.String characterEncoding) throws MimeException
replyto
- the reply-to email addresscharacterEncoding
- the character encoding to use when setting the Reply-To addressMimeException
- thrown if an error occurs while encoding Reply-To headerMimeException
public void setReplyTo(java.lang.String replyto) throws MimeException
replyto
- the reply-to email addressMimeException
- if a MIME related error occurspublic void setSubject(java.lang.String subject) throws MimeException
subject
- the subject of messageMimeException
- if a MIME related error occurspublic void setSubject(java.lang.String subject, java.lang.String characterEncoding) throws MimeException
subject
- the subject of messagecharacterEncoding
- the character encoding used when setting the Subject headerMimeException
- if a MIME related error occurspublic java.lang.String getSubject()
null
if no Subject header is presentpublic java.lang.String getFrom()
public java.lang.String getTo()
public java.lang.String getCc()
public java.lang.String getBcc()
public java.lang.String getDate()
public java.lang.String getReplyTo()
public java.lang.String getBody() throws MimeException
getBody
in class MimeMessage
MimeException
- if a MIME related error occurspublic void setPriority(int priority) throws MimeException
priority
- the message priorityMimeException
- if a MIME related error occurs while reading messagepublic int getPriority() throws MimeException
MimeException
- if a MIME related error occurs while reading messageCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved