| java.lang.Object org.apache.commons.mail.Email org.apache.commons.mail.MultiPartEmail org.apache.commons.mail.HtmlEmail
All known Subclasses: org.apache.commons.mail.mocks.MockHtmlEmailConcrete,
HtmlEmail | public class HtmlEmail extends MultiPartEmail (Code) | | 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.
since: 1.0 author: Regis Koenig author: Sean Legassick version: $Id: HtmlEmail.java 279285 2005-09-07 09:52:44Z henning $ |
Method Summary | |
public void | buildMimeMessage() Does the work of actually building the email. | public String | embed(URL url, String name) Embeds an URL in the HTML.
This method allows to embed a file located by an URL into
the mail body. | public HtmlEmail | setHtmlMsg(String aHtml) Set the HTML content.
Parameters: aHtml - A String. | public Email | setMsg(String msg) Set the message.
This method overrides the MultiPartEmail setMsg() method in
order to send an HTML message instead of a full text message in
the mail body. | public HtmlEmail | setTextMsg(String aText) Set the text content.
Parameters: aText - A String. |
CID_LENGTH | final public static int CID_LENGTH(Code) | | Definition of the length of generated CID's
|
inlineImages | protected List inlineImages(Code) | | Embedded images
|
text | protected String text(Code) | | Text part of the message. This will be used as alternative text if
the email client does not support HTML messages.
|
buildMimeMessage | public void buildMimeMessage() throws EmailException(Code) | | Does the work of actually building the email.
exception: EmailException - if there was an error. since: 1.0 |
embed | public String embed(URL url, String name) throws EmailException(Code) | | Embeds an URL in the HTML.
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)
Parameters: url - The URL of the file. Parameters: name - The name that will be set in the filename headerfield. A String with the Content-ID of the file. throws: EmailException - when URL supplied is invalidalso see javax.mail.internet.MimeBodyPart for definitions since: 1.0 |
setMsg | public Email setMsg(String msg) throws EmailException(Code) | | Set the message.
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.
Parameters: msg - A String. An Email. throws: EmailException - see javax.mail.internet.MimeBodyPartfor definitions since: 1.0 |
Methods inherited from org.apache.commons.mail.MultiPartEmail | public Email addPart(String partContent, String partContentType) throws EmailException(Code)(Java Doc) public Email addPart(MimeMultipart multipart) throws EmailException(Code)(Java Doc) public Email addPart(MimeMultipart multipart, int index) throws EmailException(Code)(Java Doc) public MultiPartEmail attach(EmailAttachment attachment) throws EmailException(Code)(Java Doc) public MultiPartEmail attach(URL url, String name, String description) throws EmailException(Code)(Java Doc) public MultiPartEmail attach(URL url, String name, String description, String disposition) throws EmailException(Code)(Java Doc) public MultiPartEmail attach(DataSource ds, String name, String description) throws EmailException(Code)(Java Doc) public MultiPartEmail attach(DataSource ds, String name, String description, String disposition) throws EmailException(Code)(Java Doc) public void buildMimeMessage() throws EmailException(Code)(Java Doc) protected BodyPart createBodyPart()(Code)(Java Doc) protected MimeMultipart createMimeMultipart()(Code)(Java Doc) protected MimeMultipart getContainer()(Code)(Java Doc) protected BodyPart getPrimaryBodyPart() throws MessagingException(Code)(Java Doc) public String getSubType()(Code)(Java Doc) protected void init()(Code)(Java Doc) public boolean isBoolHasAttachments()(Code)(Java Doc) protected boolean isInitialized()(Code)(Java Doc) public void setBoolHasAttachments(boolean b)(Code)(Java Doc) protected void setInitialized(boolean b)(Code)(Java Doc) public Email setMsg(String msg) throws EmailException(Code)(Java Doc) public void setSubType(String aSubType)(Code)(Java Doc)
|
Methods inherited from org.apache.commons.mail.Email | public Email addBcc(String email) throws EmailException(Code)(Java Doc) public Email addBcc(String email, String name) throws EmailException(Code)(Java Doc) public Email addCc(String email) throws EmailException(Code)(Java Doc) public Email addCc(String email, String name) throws EmailException(Code)(Java Doc) public void addHeader(String name, String value)(Code)(Java Doc) public Email addReplyTo(String email) throws EmailException(Code)(Java Doc) public Email addReplyTo(String email, String name) throws EmailException(Code)(Java Doc) public Email addTo(String email) throws EmailException(Code)(Java Doc) public Email addTo(String email, String name) throws EmailException(Code)(Java Doc) public void buildMimeMessage() throws EmailException(Code)(Java Doc) public InternetAddress getFromAddress()(Code)(Java Doc) public String getHostName()(Code)(Java Doc) public Session getMailSession() throws EmailException(Code)(Java Doc) public MimeMessage getMimeMessage()(Code)(Java Doc) public Date getSentDate()(Code)(Java Doc) public String getSmtpPort()(Code)(Java Doc) public String getSubject()(Code)(Java Doc) public String send() throws EmailException(Code)(Java Doc) public String sendMimeMessage() throws EmailException(Code)(Java Doc) public void setAuthentication(String userName, String password)(Code)(Java Doc) public void setAuthenticator(Authenticator newAuthenticator)(Code)(Java Doc) public Email setBcc(Collection aCollection) throws EmailException(Code)(Java Doc) public Email setBounceAddress(String email)(Code)(Java Doc) public Email setCc(Collection aCollection) throws EmailException(Code)(Java Doc) public void setCharset(String newCharset)(Code)(Java Doc) public void setContent(MimeMultipart aMimeMultipart)(Code)(Java Doc) public void setContent(Object aObject, String aContentType)(Code)(Java Doc) public void setDebug(boolean d)(Code)(Java Doc) public Email setFrom(String email) throws EmailException(Code)(Java Doc) public Email setFrom(String email, String name) throws EmailException(Code)(Java Doc) public void setHeaders(Map map)(Code)(Java Doc) public void setHostName(String aHostName)(Code)(Java Doc) public void setMailSession(Session aSession)(Code)(Java Doc) abstract public Email setMsg(String msg) throws EmailException(Code)(Java Doc) public void setPopBeforeSmtp(boolean newPopBeforeSmtp, String newPopHost, String newPopUsername, String newPopPassword)(Code)(Java Doc) public void setSentDate(Date date)(Code)(Java Doc) public void setSmtpPort(int aPortNumber)(Code)(Java Doc) public Email setSubject(String aSubject)(Code)(Java Doc) public Email setTo(Collection aCollection) throws EmailException(Code)(Java Doc) protected InternetAddress[] toInternetAddressArray(List list)(Code)(Java Doc)
|
|
|