Matt Raible has written about the JavaMail and Velocity support in the Spring Framework. The article is a short tutorial for setting up Spring's JavaMail support on a PositionManager class, followed by replacing the e-mail's text with a Velocity template. Matt is the author of the upcoming Spring Live book on the framework.
Read Matt Raible in Sending Velocity-based E-Mail with Spring
-
Featured Article: Sending Velocity-based E-Mail with Spring (5 messages)
- Posted by: Dion Almaer
- Posted on: April 07 2004 09:20 EDT
Threaded Messages (5)
- Featured Article: Sending Velocity-based E-Mail with Spring by Juergen Hoeller on April 09 2004 14:02 EDT
- DisplayTag & JasperReport by Faisal Abdelli on April 11 2004 15:09 EDT
- RE: DisplayTag & JasperReport by Matt Raible on April 12 2004 07:00 EDT
- DisplayTag & JasperReport by Faisal Abdelli on April 11 2004 15:09 EDT
- Article update: Fixed Issues by Matt Raible on April 28 2004 05:05 EDT
- VelocityMail by Sean Sullivan on March 12 2005 15:11 EST
-
Featured Article: Sending Velocity-based E-Mail with Spring[ Go to top ]
- Posted by: Juergen Hoeller
- Posted on: April 09 2004 14:02 EDT
- in response to Dion Almaer
Thanks for writing this tutorial, Matt! Spring's mail support is still among the less-than-perfectly documented parts of the framework, so this is really appreciated :-)
Three notes on further options:
1.
As alternative to specifying a resource loader in the Velocity properties, VelocityEngineFactoryBean supports a "resourceLoaderPath" property, taking any location that's resolvable by the Spring application context (e.g. "/WEB-INF/velocity") as argument. Loading from file resources rather than the classpath allows for hot-reloading of changed templates, e.g. in web apps.
Spring's ApplicationContext abstracts access to file resources to decouple components and configurations from the actual environment. In unit tests, simply load the above with a FileSystemXmlApplicationContext and specify the web app root directory as VM working directory: The resource location will get interpreted as relative file path then, rather than as ServletContext resource.
2.
Spring provides analogous support for FreeMarker 2.3: FreeMarkerConfigurationFactoryBean and FreeMarkerTemplateUtils. So using FreeMarker for generating mail content is as straightforward as using Velocity. FreeMarkerConfigurationFactoryBean also supports a "templateLoaderPath", analogous to VelocityEngineFactoryBean's "resourceLoaderPath".
3.
For more powerful mail options (multipart mails etc), you can use the JavaMailSender interface with JavaMail's MimeMessage class, instead of MailSender with SimpleMailMessage. As a further convenience, Spring provides the MimeMessageHelper class for populating a MimeMessage, also supporting file attachments. See MimeMessageHelper's javadoc for a usage example.
Juergen -
DisplayTag & JasperReport[ Go to top ]
- Posted by: Faisal Abdelli
- Posted on: April 11 2004 15:09 EDT
- in response to Juergen Hoeller
Hi Matt,
First I have to thank all raibledesigns.com team for providing such good component - DisplayTag and the better than Monster's Struts Resume web application.
My Question is: Is is possible to use DisplayTag as an HTML view to JasperReport?
Keep up the good work
Faisal -
RE: DisplayTag & JasperReport[ Go to top ]
- Posted by: Matt Raible
- Posted on: April 12 2004 07:00 EDT
- in response to Faisal Abdelli
Faisal - you're probably best off asking this question on the < href="http://displaytag.sourceforge.net/mail-lists.html">DisplayTag User</a> mailing list. That being said, I don't think so. The displaytag can (currently) only be used in JSP pages. -
Article update: Fixed Issues[ Go to top ]
- Posted by: Matt Raible
- Posted on: April 28 2004 05:05 EDT
- in response to Dion Almaer
FYI...
I solved the two issues I had in this article: initializing Velocity more than once, and loading templates from the database. -
VelocityMail[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: March 12 2005 15:11 EST
- in response to Dion Almaer