commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject RE: [email] Using Templates for Mail Message
Date Fri, 02 Dec 2005 14:02:36 GMT
Herak,

Why wouldn't you use something like Velocity for this?  Velocity is very
well equipped to handle these sorts of tasks and that's exactly what I use
for generating "system" emails.  Commons email doesn't need any utility for
this.  The body of an email is (for the most part) simply a string and you
can easily generate that using Velocity.  If you'd like a copy of a class I
wrote (VelocityUtils) which makes it easy to turn a velocity template into a
String, let me know.  I'll mail it to you directly.  It works quite well.

James

-----Original Message-----
From: Herak Sen [mailto:heraksen@yahoo.com] 
Sent: Friday, December 02, 2005 2:25 AM
To: Jakarta Commons Developers List
Subject: [email] Using Templates for Mail Message

Hi,
A very common method which I use for setting messages is by loading from an
external file and replace some tokens with desired values.
For e.g.
  ------------------------------------------------------------------
  AUTO-GENERATED MESSAGE FOLLOWS. PLEASE DO NOT REPLY TO THIS EMAIL.
  -------------------------------------------------------------------
  Hello,
  You have been successfully registered.
  Login Detail 
  login :@LOGIN@
  pwd :@PWD@
  -----------------------------------------------------------------
  After reading this file, I replace @LOGIN@ and @PWD@ with the appropriate
values and then send the contents.
I was wondering whether such feature could be incorporated in API. 
There could be a class something like the following
  public class Template{
    private String template;
    public Template(InputStream in){
       template=loadTemplate(in);
    }
    public String replaceTokens(Map map){
     //Replace all string within @@
      return template;
    }
  }
   
  May be have a more sophisticated implementation for various data sources.
  Please share your views.
  
Thanks
Herak
   

		
---------------------------------
 Yahoo! Personals
 Let fate take it's course directly to your email.
 See who's waiting for you Yahoo! Personals



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message