Skip to content

Instantly share code, notes, and snippets.

@martinnormark
Created January 24, 2012 07:56
Show Gist options
  • Save martinnormark/1668751 to your computer and use it in GitHub Desktop.
Save martinnormark/1668751 to your computer and use it in GitHub Desktop.
Read file contents into a string variable
MailDefinition md = new MailDefinition();
md.From = "[email protected]";
md.IsBodyHtml = true;
md.Subject = "Test of MailDefinition";
ListDictionary replacements = new ListDictionary();
replacements.Add("<%Name%>", "Martin");
replacements.Add("<%Country%>", "Denmark");
string body = String.Empty;
using (StreamReader sr = new StreamReader(@"C:\Path\To\File.txt"))
{
body = sr.ReadToEnd();
}
MailMessage msg = md.CreateMailMessage("[email protected]", replacements, body, new System.Web.UI.Control());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment