Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I store email templates for emails sent out at the end of a batch run?

So I'm writing this EXE to process refunds, and when the job's done, we're sending out an email to a list of users that will probably be like:

DO NOT REPLY

Refund processing has completed. N refunds were successfully processed. We encountered N errors. Please check http://whatever.url for a detailed report.

Thanks,

A computer

DO NOT REPLY

So, we're not talking about grinding out hundreds of emails here, just one a day with the relevant info slipstreamed in. It's unlikely that this email will ever be modified, and never by non-technical staff. How should I go about storing this and processing the template into the email? C# String.Format style with {0} and {1}, etc? XML/XSLT (seems like a hassle)? Do I store the template in App.config or put it in the database or something different altogether?

What did I ever do before StackOverflow? :)

like image 961
Chris McCall Avatar asked Dec 03 '22 07:12

Chris McCall


1 Answers

I would take the easy way out. I assume you want to send a HTML mail message here.

I suggest you create a HTML file with how you want the mail to look. Replace all names/variables with things like #COMPANYNAME#. save the file and rightclick on your Project in Visual Studio. Go to Properties then Resources. Now drag the HTML file into the resources and give it a decent name (here: MyMailTemplate).

Now from your code you can refer to it from Properties.Resources.MyMailTemplate. You can use it as a string. Replace the #PARAMETER# text with the actual values.

Done and easy to edit!

like image 193
Zyphrax Avatar answered Dec 04 '22 20:12

Zyphrax