// Print message body Console.WriteLine("Body:"); if (message.IsBodyHtml) { Console.WriteLine(message.HtmlBody);
// Save HTML message body as a page FileStream outFile = File.OpenWrite(@"C:\Dev\Mail\MailBody.html"); StreamWriter writer = new StreamWriter(outFile); writer.Write(message.HtmlBody); writer.Close(); } else { Console.WriteLine(message.Body); }
// Print and save mail's attachments Console.WriteLine("Attachments:"); foreach (var attach in message.Attachments) { Console.WriteLine(attach.Name + attach.ContentType); attach.Save(@"C:\Dev\Mail\" + attach.Name); } } } }