• Post Reply Bookmark Topic Watch Topic
  • New Topic

designing java interface for email template  RSS feed

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I'm building a
java interface (class) for my web appln. Basically, I want this
interface to be an email interface (internally I will use JavaMail
to send messages. The email contents and recipient lists are all
to be dynamicallly generated. I want some ideas on the design.
For the FROM, TO, CC, BCC lists, I plan to have setter methods.
However, the subject and BODY are in the form of standard text
files with PLACEHOLDERS for dynamic text inclusion.
I am thinking of using xml files for the different email templates. However, I'm a little unsure of how to use PLACEHOLDERS (eg. would they be EMPTY elements?).
Do you think, it is worthwhile including an xml parser into my
app for this purpose. There is likely to be additional templates, in future.
The email interface that I build, should be generic enough to read
these templates and include the dynamic content at placeholder
and generate emails to recipient list.
If you have the time, do send me your thoughts on how you would
approach this. I'm trying to think of the simplest way to implement
Shd. I go text file and do parsing on my own or go XML way....?
mock template eg:-
subject: project [PROJ_NAME] has been approved
This email is to let you know that the project [PROJ_NAME] has
been approved with the foll. info
Project Start date : [START_DATE]
project end date : [END_DATE]
budget : [$AMOUNT]
This is for your informational purpose only.
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The world already has enough mature templating languages; I would think you'd have to come up with very good reasons to come up with a new one. Take your pick:
  • XSLT. Expose your data as XML, use XSLT to turn it into an e-mail.
  • If you're in a web container, you can use a JSP to render your e-mail.
  • Velocity.
  • Freemarker.
  • And so forth...
  • Take your pick; no need to reinvent the wheel.
    - Peter
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!