Matt, we ended up storing our email templates in a configuration file and loading them into memory (using Digester) at application run time. The configuration templates can contain both plain text and HTML message versions. We leverage the java.text.MessageFormat API to replace place holders in the templates with actual data.
In the application, we use a design pattern called EmailHelper. EmailHelper provides a business API to which the application passes information. For example, after a customer downloads a product, the application might do something like: EmailHelper.getInstance().sendThankYouMessage(user, product); where user and product are application data structures respectively representing the current user and the product which was just downloaded. Subsequently, EmailHelper mines the necessary data from the arguments and then performs lower level operations such as retrieving the appropriate email template from the in memory configurations, populating the template and then persisting the email to the appropriate queue where it will be delivered later. A different application (daemon) periodically retrieves unsent email from the queue and sends them using the JavaMail API. It has worked quite well so far. If we need to tweak the templates, we can do so and reload the configurations. You could take this idea a step further and store the templates in the database. This does seem like a common task in applications and it would be nice if there were some standard framework to use, but I don't know of any in development currently. robert > -----Original Message----- > From: Matt Bathje [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 11:03 AM > To: strutslist > Subject: [OT] Sending email from struts > > > Hi all. > > This is kind of off topic as it is not really struts related, but somebody > here would probably have the answer. > > We have our application sending emails to users at some points and it is > working fine. The problem is that we have the email message hardcoded into > the Java, which we would like to avoid either by storing the message in > application.properties or our database. This would be easy, except all of > the messages contain user-specific information like their name or phone > number or order id or something like that. > > Anybody have any ideas (or links to programs!) that can read in an email, > replace the information it needs to from the db, and send that to > the user. > > I could obviously write something myself to do it, but wouldn't want to > reinvent the wheel. > > Turns out this is hard to search for too - email is not a search term that > makes things easy. > > Thanks, > Matt Bathje > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

