org.apache.turbine.util.webmacro
Class WebMacroHtmlEmail

java.lang.Object
  |
  +--org.apache.turbine.util.mail.Email
        |
        +--org.apache.turbine.util.mail.MultiPartEmail
              |
              +--org.apache.turbine.util.mail.HtmlEmail
                    |
                    +--org.apache.turbine.util.webmacro.WebMacroHtmlEmail

Deprecated. you should use velocity

public class WebMacroHtmlEmail
extends HtmlEmail

This is a simple class for sending html email from within WebMacro. Essentially, the bodies (text and html) of the email are a WebMacro Context objects. The beauty of this is that you can send email from within your WebMacro template or from your business logic in your Java code. The body of the email is just a WebMacro template so you can use all the template functionality of WebMacro within your emails!

This class allows you to send HTML email with embedded content and/or with attachments. You can access the WebMacroHtmlEmail instance within your templates trough the $mail WebMacro variable.

The templates should be located under your Template turbine directory.

This class extends the HtmlEmail class. Thus, it uses the JavaMail API and also depends on having the mail.server property set in the TurbineResources.properties file. If you want to use this class outside of Turbine for general processing that is also possible by making sure to set the path to the TurbineResources.properties. See the TurbineConfig class for more information.

Version:
$Id: WebMacroHtmlEmail.java,v 1.1.1.1 2001/08/16 05:10:05 jvanzyl Exp $
Author:
Regis Koenig, Jon S. Stevens

Field Summary
private  org.webmacro.servlet.WebContext context
          Deprecated. A WebContext
private  java.util.Hashtable embmap
          Deprecated. The map of embedded files.
private  java.lang.String htmlTemplate
          Deprecated. The html template to process, relative to WM's template directory.
private  java.lang.String textTemplate
          Deprecated. The text template to process, relative to WM's template directory.
 
Fields inherited from class org.apache.turbine.util.mail.HtmlEmail
html, htmlContent, text
 
Fields inherited from class org.apache.turbine.util.mail.MultiPartEmail
emailBody, fileServer, main
 
Fields inherited from class org.apache.turbine.util.mail.Email
ATTACHMENTS, bccList, ccList, 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, replyList, SENDER_EMAIL, SENDER_NAME, SMTP, TEXT_HTML, TEXT_PLAIN, toList, US_ASCII
 
Constructor Summary
WebMacroHtmlEmail()
          Deprecated. Constructor, sets the RunData object.
 
Method Summary
 java.lang.String embed(java.lang.String surl, java.lang.String name)
          Deprecated. Embed a file in the mail.
 java.lang.String getCid(java.lang.String filename)
          Deprecated. Get the cid of an embedded file.
 org.webmacro.servlet.WebContext getContext()
          Deprecated. Get the context object that will be merged with the template.
 void send()
          Deprecated. Actually send the mail.
 WebMacroHtmlEmail setContext(org.webmacro.servlet.WebContext context)
          Deprecated. Set the context object that will be merged with the template.
 WebMacroHtmlEmail setHtmlTemplate(java.lang.String template)
          Deprecated. Set the HTML template for the mail.
 WebMacroHtmlEmail setTextTemplate(java.lang.String template)
          Deprecated. Set the text template for the mail.
 
Methods inherited from class org.apache.turbine.util.mail.HtmlEmail
embed, getHtmlContent, setHtmlMsg, setHtmlMsg, setMsg, setTextMsg
 
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, getMailSession, initialize, setCharset, setFrom, setSentDate, setSubject, toInternetAddressArray
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

htmlTemplate

private java.lang.String htmlTemplate
Deprecated. 
The html template to process, relative to WM's template directory.

textTemplate

private java.lang.String textTemplate
Deprecated. 
The text template to process, relative to WM's template directory.

embmap

private java.util.Hashtable embmap
Deprecated. 
The map of embedded files.

context

private org.webmacro.servlet.WebContext context
Deprecated. 
A WebContext
Constructor Detail

WebMacroHtmlEmail

public WebMacroHtmlEmail()
                  throws javax.mail.MessagingException
Deprecated. 
Constructor, sets the RunData object.
Parameters:
data - A Turbine RunData object.
Throws:
MessagingException. -  
Method Detail

setHtmlTemplate

public WebMacroHtmlEmail setHtmlTemplate(java.lang.String template)
Deprecated. 
Set the HTML template for the mail. This is the Webmacro template to execute for the HTML part. Path is relative to the WM templates directory.
Parameters:
template - A String.
Returns:
A WebMacroHtmlEmail (self).

setTextTemplate

public WebMacroHtmlEmail setTextTemplate(java.lang.String template)
Deprecated. 
Set the text template for the mail. This is the Webmacro template to execute for the text part. Path is relative to the WM templates directory
Parameters:
template - A String.
Returns:
A WebMacroHtmlEmail (self).

setContext

public WebMacroHtmlEmail setContext(org.webmacro.servlet.WebContext context)
Deprecated. 
Set the context object that will be merged with the template.
Parameters:
context - A WebMacro context object.
Returns:
A WebMacroEmail (self).

getContext

public org.webmacro.servlet.WebContext getContext()
Deprecated. 
Get the context object that will be merged with the template.
Returns:
A WebContext (self).

send

public void send()
          throws javax.mail.MessagingException
Deprecated. 
Actually send the mail.
Overrides:
send in class HtmlEmail
Throws:
MessagingException. -  

embed

public java.lang.String embed(java.lang.String surl,
                              java.lang.String name)
                       throws javax.mail.MessagingException
Deprecated. 
Embed a file in the mail. The file can be referenced through its Content-ID. This function also registers the CID in an internal map, so the embedded file can be referenced more than once by using the getCid() function. This may be useful in a template.

Example of template:

 <html>
 <!-- $mail.embed("http://server/border.gif","border.gif"); -->
 <img src=$mail.getCid("border.gif")>
 <p>This is your content
 <img src=$mail.getCid("border.gif")>
 </html>
 
Parameters:
surl - A String.
name - A String.
Returns:
A String with the cid of the embedded file.
Throws:
MessagingException. -  
See Also:
embed.

getCid

public java.lang.String getCid(java.lang.String filename)
Deprecated. 
Get the cid of an embedded file.
Parameters:
filename - A String.
Returns:
A String with the cid of the embedded file.
See Also:
embed.


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