Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created December 16, 2011 02:18
Show Gist options
  • Save rodolfofadino/1484120 to your computer and use it in GitHub Desktop.
Save rodolfofadino/1484120 to your computer and use it in GitHub Desktop.
Example [MailMessage.AlternateViews Property ]
MailMessage mailMsg = new MailMessage();
// To
mailMsg.To.Add(new MailAddress("to@example.com", "To Name"));
// From
mailMsg.From = new MailAddress("from@example.com", "From Name");
// Subject
mailMsg.Subject = "subject";
//Texto
string text = "text body";
//Html
string html = @"<p>html body</p>";
//View Texto
mailMsg.AlternateViews.Add(
AlternateView.CreateAlternateViewFromString
(text, null, MediaTypeNames.Text.Plain));
//View Html
mailMsg.AlternateViews.Add(
AlternateView.CreateAlternateViewFromString
(html, null, MediaTypeNames.Text.Html));
//Send
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMsg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment