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? :)
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With