org.apache.turbine.util.mail
Class HtmlEmail

java.lang.Object
  extended byorg.apache.turbine.util.mail.Email
      extended byorg.apache.turbine.util.mail.MultiPartEmail
          extended byorg.apache.turbine.util.mail.HtmlEmail

Deprecated. Use org.apache.commons.mail.HtmlEmail instead.

public class HtmlEmail
extends MultiPartEmail

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 attachents 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 alternate 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.

Version:
$Id: HtmlEmail.java 264148 2005-08-29 14:21:04Z henning $
Author:
Regis Koenig, Sean Legassick

Field Summary
protected  java.lang.String html
          Deprecated.  
protected  javax.mail.internet.MimeMultipart htmlContent
          Deprecated.  
protected  java.lang.String text
          Deprecated.  
 
Fields inherited from class org.apache.turbine.util.mail.MultiPartEmail
emailBody, main
 
Fields inherited from class org.apache.turbine.util.mail.Email
ATTACHMENTS, charset, CONTENT_TYPE, EMAIL_BODY, EMAIL_SUBJECT, FILE_SERVER, ISO_8859_1, KOI8_R, MAIL_HOST, MAIL_SERVER, MAIL_SMTP_FROM, MAIL_TRANSPORT_PROTOCOL, message, RECEIVER_EMAIL, RECEIVER_NAME, SENDER_EMAIL, SENDER_NAME, SMTP, TEXT_HTML, TEXT_PLAIN, US_ASCII
 
Constructor Summary
HtmlEmail()
          Deprecated. Basic constructor.
 
Method Summary
 java.lang.String embed(java.net.URL url, java.lang.String name)
          Deprecated. Embeds an URL in the HTML.
 javax.mail.internet.MimeMultipart getHtmlContent()
          Deprecated. Instantiates a new MimeMultipart object if it isn't already instantiated.
 void send()
          Deprecated. Does the work of actually sending the email.
 HtmlEmail setHtmlMsg(org.apache.ecs.Document doc)
          Deprecated. Set the HTML content based on an ECS document.
 HtmlEmail setHtmlMsg(java.lang.String html)
          Deprecated. Set the HTML content.
 Email setMsg(java.lang.String msg)
          Deprecated. Set the message.
 HtmlEmail setTextMsg(java.lang.String text)
          Deprecated. Set the text content.
 
Methods inherited from class org.apache.turbine.util.mail.MultiPartEmail
attach, attach, attach, attach, attach, init, initCriteria
 
Methods inherited from class org.apache.turbine.util.mail.Email
addBcc, addCc, addReplyTo, addTo, initialize, setCharset, setFrom, setSentDate, setSubject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

htmlContent

protected javax.mail.internet.MimeMultipart htmlContent
Deprecated. 

text

protected java.lang.String text
Deprecated. 

html

protected java.lang.String html
Deprecated. 
Constructor Detail

HtmlEmail

public HtmlEmail()
          throws javax.mail.MessagingException
Deprecated. 
Basic constructor.

Throws:
MessagingException.
javax.mail.MessagingException
Method Detail

getHtmlContent

public javax.mail.internet.MimeMultipart getHtmlContent()
Deprecated. 
Instantiates a new MimeMultipart object if it isn't already instantiated.

Returns:
A MimeMultipart object

setTextMsg

public HtmlEmail setTextMsg(java.lang.String text)
                     throws javax.mail.MessagingException
Deprecated. 
Set the text content.

Parameters:
text - A String.
Returns:
An HtmlEmail.
Throws:
MessagingException.
javax.mail.MessagingException

setHtmlMsg

public HtmlEmail setHtmlMsg(java.lang.String html)
                     throws javax.mail.MessagingException
Deprecated. 
Set the HTML content.

Parameters:
html - A String.
Returns:
An HtmlEmail.
Throws:
MessagingException.
javax.mail.MessagingException

setHtmlMsg

public HtmlEmail setHtmlMsg(org.apache.ecs.Document doc)
                     throws javax.mail.MessagingException
Deprecated. 
Set the HTML content based on an ECS document.

Parameters:
doc - A Document.
Returns:
An HtmlEmail.
Throws:
MessagingException.
javax.mail.MessagingException

setMsg

public Email setMsg(java.lang.String msg)
             throws javax.mail.MessagingException
Deprecated. 
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.

Overrides:
setMsg in class MultiPartEmail
Parameters:
msg - A String.
Returns:
An Email.
Throws:
MessagingException.
javax.mail.MessagingException

embed

public java.lang.String embed(java.net.URL url,
                              java.lang.String name)
                       throws javax.mail.MessagingException
Deprecated. 
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.
name - The name that will be set in the filename header field.
Returns:
A String with the Content-ID of the file.
Throws:
MessagingException.
javax.mail.MessagingException

send

public void send()
          throws javax.mail.MessagingException
Deprecated. 
Does the work of actually sending the email.

Overrides:
send in class Email
Throws:
MessagingException, - if there was an error.
javax.mail.MessagingException


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.