Send email. Set body from HTML file
Posted on 2010-08-26
I am sending out an email very simply using the below code from within a WinApp not ASP
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.IsBodyHtml = true;
message.Subject = "";
message.From = new System.Net.Mail.MailAddress("");
message.Body = "";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("");
I am working on something that is needed to send out emails based on templates. So I was curious if there was a way to build the BODY of the email from an external .html file. It would make for this to be so much nicer versus having to put a thousand lines of HTML code within the message.Body STRING.
I have another question which is, can I setup on the HTML page I create "if the above is even possible" to accept arguments/params to send the email off as well? An example would be that I have a block such as [USERNAME] supplied on the html page. I would pass the current username to the HTML page, and that is what would be sent to the user. I've seen doing this with Resource files, but I really would like to stay away from that approach otherwise I will have to accomadate some else that is off topic.