This is a simple class for sending html email from within Velocity.
Essentially, the bodies (text and html) of the email are a Velocity
Context objects. The beauty of this is that you can send email
from within your Velocity template or from your business logic in
your Java code. The body of the email is just a Velocity template
so you can use all the template functionality of Velocity within
your emails!
This class allows you to send HTML email with embedded content
and/or with attachments. You can access the VelocityHtmlEmail
instance within your templates trough the $mail
Velocity variable.
VelocityHtmlEmail myEmail= new VelocityHtmlEmail(data);
context.put("mail", myMail);
or
VelocityHtmlEmail myEmail= new VelocityHtmlEmail(context);
context.put("mail", myMail);
The templates should be located under your Template turbine
directory.
This class wraps the HtmlEmail class from commons-email. 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
TurbineResourceService.setPropertiesFileName() method for more
information.
This class is basically a conversion of the WebMacroHtmlEmail
written by Regis Koenig
You can turn on debugging for the JavaMail API by calling
setDebug(true). The debugging messages will be written to System.out.
author: Eric Pugh author: Andre Schild author: Quinton McCombs author: Henning P. Schmiedehausen version: $Id: VelocityHtmlEmail.java 534527 2007-05-02 16:10:59Z tv $ |