Reputation: 47
I'm trying to put together a newsletter that links to articles on a website through Visual Studio windows forms. I can successfully pull out the article links which are stored in a SQL Server database.
My problem is how to handle the rest of the HTML email, for example how can I store the rest of the HTML body, style tags etc without making my code a complete mess, I've tried breaking it up into several parts stored in several string variables but then realised
Basically I just need some advice on how to handle the HTML body content of the email to then add in my articles, which are pulled from a SQL Server database, into the HTML
Upvotes: 0
Views: 492
Reputation: 175936
Keep the static email text outside of your application; create a template file (or field in the db) using {CONTENT} / {TITLE}
style placeholder strings, load the file and replace("{CONTENT}", db_value)
for all the values you need.
There is also the built in MailDefinition
class from System.Web
which does the same.
Upvotes: 1