[RESOLVED] Creating and populating email templates
I have a page that is called from loads of different pages that basically sends emails. It has text boxes for Subject, From Address etc. and a textbox like the one I am typing in now (on this site) which allows users to format a html message.
I need to develop the functionality by providing email templates for the message.
So, the template text (which will be stored and retrieved from a database) might contain:
Dear .......
Thanks for attending the meeting.
Kind regards
.......
Where the ...... are, I would want to fill in the name of the person who is going to receive the email and the name of the person sending it.
So, I'm on the page - I've retrieved the text for the message from the database - I have SendersName and ReceiversName sitting there in variables - how do I get them in the text in the right place?
I was thinking I could make the template text look like this:-
Dear [ReceiversName]
Thanks for attending the meeting.
Kind regards
[SendersName]
and then, on the page, just Replace the various 'tags'. Is this a good idea?
Thanks for any suggestions.
Re: Creating and populating email templates
Re: Creating and populating email templates
@Webskater, what you have proposed is actually a good idea, one that I have used in a few projects in the past.
If you want more sophistication, you could explore the XML/XSLT alternative, but it might be an overkill. For a simple template-based email app, inserting placeholders in the template and then replacing them with the actual values should work best.
.
Re: Creating and populating email templates
Webskater,
You can find an example here:
http://dotnettricks.com/blogs/roberh.../05/12/57.aspx
Hope that helps!
Gary
Re: Creating and populating email templates
Thanks for all the replies. To be honest I thought it was a bit of a daft question, but it wasn't. I didn't know anything about what is shown in the link Gary provided - and that is just what I was after.
Thanks again.
Re: [RESOLVED] Creating and populating email templates
Not a problem at all, happy to help!!
Let us know if you have any problems.
Gary