public static void Run()
{
// Declare msg as MailMessage instance
MailMessage msg = new MailMessage();
// Use MailMessage properties like specify sender, recipient, message and HtmlBody
msg.From = "[email protected]";
msg.To = "[email protected]";
msg.Subject = "Test subject";
msg.HtmlBody = "<html><body>This is the HTML body</body></html>";
SmtpClient client = GetSmtpClient();
try
{
// Client will send this message
client.Send(msg);
Console.WriteLine("Message sent");
}
catch (Exception ex)
{
Trace.WriteLine(ex.ToString());
}
Console.WriteLine(Environment.NewLine + "Email sent with HTML body.");
}