views:

111

answers:

2

From the "It must have been done 1 million times before" department...I need to integrate a email templating solution into an existing .Net product. Right now, each component (workflow, admin, etc) sends out their own hard-coded emails. I would like to introduce a new admin site/screen that allows users to pick from a set of email templates. The templates themselves will be fairly simplistic, with some string substitution based on business rules.

Question is: is there a design pattern that covers the creation and usage of email templates? Examples? I have started to look at Strategy and the Template Design Pattern.

A: 

If you want to make it simple and use existing technologies as much as possible, I would suggest implement it using XSL templates (to generate e-mail body in HTML or plain-text format).

I will also suggest looking at system.web.ui.webcontrols.maildefinition

You can find some ready templates on the market (templateengine.net) and also SSRS can be used as e-mail generator, but this will be probably an overkill.

Bogdan_Ch
A: 

This isn't really a design pattern, at least not the one in the "Strategy" or "Template Method" category. The closest thing I would say this comes to is the Builder pattern, but I guess it would be an overkill unless your business rules are complex.

As for the templating itself, I suggest you take a look at NVelocity.

Igor Brejc
Personally, I don't recommend NVelocity. It's an awful port. More details over at http://stackoverflow.com/questions/346449/templating-engine-to-generate-simple-reports-in-net
Nicholas Piasecki