public static void Run()
{
try
{
// ExStart:SendMessageAsTNEF
var emlFileName = RunExamples.GetDataDir_Email() + "Message.eml"; // A TNEF Email
// Load from eml
MailMessage eml1 = MailMessage.Load(emlFileName, new EmlLoadOptions());
eml1.From = "[email protected]";
eml1.To.Clear();
eml1.To.Add(new MailAddress("[email protected]"));
eml1.Subject = "With PreserveTnef flag during loading";
eml1.Date = DateTime.Now;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "somename", "password");
client.SecurityOptions = SecurityOptions.Auto;
client.UseTnef = true; // Use this flag to send as TNEF
client.Send(eml1);
// ExEnd:SendMessageAsTNEF
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
}