public class HtmlEmailMessage extends EmailMessage
HtmlEmailMessage message = new HtmlEmailMessage(); message.setTo("jsmith@myserver.com"); message.setFrom("rjones@myserver.com"); message.setSubject("Meeting at 8"); message.setTextBody("this is the text body"); message.setHtmlBody("<html><body><img src=\"cid:12345\"><br>this is the html body</body></html>"); message.embed(new URL("http://www.domain.com/image.gif","12345");
Constructor and Description |
---|
HtmlEmailMessage()
Creates a new HtmlEmailMessage instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(Attachment att)
Adds attachment to email message.
|
void |
embed(java.io.File file,
java.lang.String id)
Embeds a resource in the email message.
|
void |
embed(java.net.URL url,
java.lang.String id)
Embeds a resource in the email message.
|
byte[] |
getMessage()
Gets contents of this
HtmlEmailMessage . |
void |
setHtmlBody(java.io.File htmlBody)
Sets the HTML portion of this email message from contents of a file.
|
void |
setHtmlBody(java.lang.String htmlBody)
Sets the HTML portion of this email message.
|
void |
setTextBody(java.io.File textBody)
Sets the plain text portion of this email message from contents of a file.
|
void |
setTextBody(java.lang.String textBody)
Sets the plain text portion of this email message.
|
addAttachment, getAttachments, getBcc, getBody, getCc, getContentType, getDate, getFrom, getPriority, getReplyTo, getSubject, getTo, setBcc, setCc, setCc, setContentType, setContentType, setFrom, setFrom, setPriority, setReplyTo, setReplyTo, setSubject, setSubject, setTo, setTo
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 HtmlEmailMessage() throws MimeException
MimeException
- if a MIME related error occurspublic void addAttachment(Attachment att) throws MimeException
attachment
and false
as method argument to ensure that existing body is not added as a separate MIME part.addAttachment
in class EmailMessage
att
- the attachment to addMimeException
- if a MIME related error occurspublic void setTextBody(java.lang.String textBody)
textBody
- the plain text portion of this messagepublic void setHtmlBody(java.lang.String htmlBody)
htmlBody
- the HTML portion of this messagepublic void setHtmlBody(java.io.File htmlBody) throws java.io.IOException
htmlBody
- file containing HTML bodyjava.io.IOException
- if an I/O error occurspublic void setTextBody(java.io.File textBody) throws java.io.IOException
textBody
- file containing text bodyjava.io.IOException
- if an I/O error occurspublic void embed(java.net.URL url, java.lang.String id)
url
- the URL of the resourceid
- the unique Content-ID header value of the resource referenced in the HTML codepublic void embed(java.io.File file, java.lang.String id)
file
- the resource fileid
- the unique Content-ID header value of the resource referenced in the HTML codepublic byte[] getMessage() throws MimeException
HtmlEmailMessage
. Contents include all
MIME message headers, body and any parts.getMessage
in class EmailMessage
MimeException
- if a MIME related parsing error occursCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved