|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.mail.Email
org.apache.commons.mail.MultiPartEmail
railo.runtime.net.mail.HtmlEmailImpl
public final class HtmlEmailImpl
An HTML multipart email.
This class is used to send HTML formatted email. A text message can also be set for HTML unaware email clients, such as text-based email clients.
This class also inherits from MultiPartEmail, so it is easy to add attachments to the email.
To send an email in HTML, one should create a HtmlEmail, then use the setFrom, addTo, etc. methods. The HTML content can be set with the setHtmlMsg method. The alternative text content can be set with setTextMsg.
Either the text or HTML can be omitted, in which case the "main" part of the multipart becomes whichever is supplied rather than a multipart/alternative.
Field Summary | |
---|---|
static int |
CID_LENGTH
Definition of the length of generated CID's |
Fields inherited from class org.apache.commons.mail.Email |
---|
ATTACHMENTS, CONTENT_TYPE, EMAIL_BODY, EMAIL_SUBJECT, FILE_SERVER, ISO_8859_1, KOI8_R, MAIL_DEBUG, MAIL_HOST, MAIL_PORT, MAIL_SMTP_AUTH, MAIL_SMTP_CONNECTIONTIMEOUT, MAIL_SMTP_FROM, MAIL_SMTP_PASSWORD, MAIL_SMTP_SOCKET_FACTORY_CLASS, MAIL_SMTP_SOCKET_FACTORY_FALLBACK, MAIL_SMTP_SOCKET_FACTORY_PORT, MAIL_SMTP_TIMEOUT, MAIL_SMTP_USER, MAIL_TRANSPORT_PROTOCOL, MAIL_TRANSPORT_TLS, RECEIVER_EMAIL, RECEIVER_NAME, SENDER_EMAIL, SENDER_NAME, SMTP, TEXT_HTML, TEXT_PLAIN, US_ASCII |
Constructor Summary | |
---|---|
HtmlEmailImpl()
|
Method Summary | |
---|---|
void |
buildMimeMessage()
Does the work of actually building the email. |
void |
embed(URL url,
String cid,
String name)
Embeds an URL in the HTML. |
HtmlEmailImpl |
setHtmlMsg(String aHtml)
Set the HTML content. |
org.apache.commons.mail.Email |
setMsg(String msg)
Set the message. |
HtmlEmailImpl |
setTextMsg(String aText)
Set the text content. |
Methods inherited from class org.apache.commons.mail.MultiPartEmail |
---|
addPart, addPart, addPart, attach, attach, attach, attach, attach, getSubType, isBoolHasAttachments, setBoolHasAttachments, setSubType |
Methods inherited from class org.apache.commons.mail.Email |
---|
addBcc, addBcc, addBcc, addCc, addCc, addCc, addHeader, addReplyTo, addReplyTo, addReplyTo, addTo, addTo, addTo, getBccAddresses, getCcAddresses, getFromAddress, getHostName, getMailSession, getMimeMessage, getReplyToAddresses, getSentDate, getSmtpPort, getSocketConnectionTimeout, getSocketTimeout, getSslSmtpPort, getSubject, getToAddresses, isSSL, isTLS, send, sendMimeMessage, setAuthentication, setAuthenticator, setBcc, setBounceAddress, setCc, setCharset, setContent, setContent, setDebug, setFrom, setFrom, setFrom, setHeaders, setHostName, setMailSession, setMailSessionFromJNDI, setPopBeforeSmtp, setReplyTo, setSentDate, setSmtpPort, setSocketConnectionTimeout, setSocketTimeout, setSSL, setSslSmtpPort, setSubject, setTLS, setTo, updateContentType |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CID_LENGTH
Constructor Detail |
---|
public HtmlEmailImpl()
Method Detail |
---|
public HtmlEmailImpl setTextMsg(String aText) throws org.apache.commons.mail.EmailException
aText
- A String.
org.apache.commons.mail.EmailException
- see javax.mail.internet.MimeBodyPart
for definitionspublic HtmlEmailImpl setHtmlMsg(String aHtml) throws org.apache.commons.mail.EmailException
aHtml
- A String.
org.apache.commons.mail.EmailException
- see javax.mail.internet.MimeBodyPart
for definitionspublic org.apache.commons.mail.Email setMsg(String msg) throws org.apache.commons.mail.EmailException
This method overrides the MultiPartEmail setMsg() method in order to send an HTML message instead of a full text message in the mail body. The message is formatted in HTML for the HTML part of the message, it is let as is in the alternate text part.
setMsg
in class org.apache.commons.mail.MultiPartEmail
msg
- A String.
org.apache.commons.mail.EmailException
- see javax.mail.internet.MimeBodyPart
for definitionspublic void embed(URL url, String cid, String name) throws org.apache.commons.mail.EmailException
This method allows to embed a file located by an URL into
the mail body. It allows, for instance, to add inline images
to the email. Inline files may be referenced with a
cid:xxxxxx
URL, where xxxxxx is the Content-ID
returned by the embed function.
Example of use:
HtmlEmail he = new HtmlEmail();
he.setHtmlMsg("<html><img src=cid:" +
embed("file:/my/image.gif","image.gif") +
"></html>");
// code to set the others email fields (not shown)
url
- The URL of the file.cid
- A String with the Content-ID of the file.name
- The name that will be set in the filename header
field.
org.apache.commons.mail.EmailException
- when URL supplied is invalid
also see javax.mail.internet.MimeBodyPart for definitionspublic void buildMimeMessage() throws org.apache.commons.mail.EmailException
buildMimeMessage
in class org.apache.commons.mail.MultiPartEmail
org.apache.commons.mail.EmailException
- if there was an error.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |