A clean technique or library for creating emails in Java

Our application currently generates emails for clients using the classic "line break" mixed with some String.replace calls.

Does anyone have a suggestion for a simple / elegant / reliable way to generate emails? We are not asking for the most bizarre things in the world. Our application uses GWT / Guice, so we do not have jsps / struts pages.

+3
source share
2 answers

You can do this with Velocity or Freemarker . For this, an example of Spring and Velocity is used . Although I have not tried this on Guice, I would suggest that the example will transfer, since Spring is injecting a speed engine.

+4
source

java.util.MessageFormat.

Alternatively, and in a much more powerful way, save your template as XML with tags for the parameters you want to replace; use XSLT for substitution and XPath for extracting only text from an XML document after processing.

+3
source

All Articles