public static void Run() { try { // ExStart:SendTaskRequestUsingIEWSClient string dataDir = RunExamples.GetDataDir_Exchange(); // Create instance of ExchangeClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); MsgLoadOptions options = new MsgLoadOptions(); options.PreserveTnefAttachments = true; // load task from .msg file MailMessage eml = MailMessage.Load(dataDir + "task.msg", options); eml.From = "*****@*****.**"; eml.To.Clear(); eml.To.Add(new MailAddress("*****@*****.**")); client.Send(eml); // ExEnd:SendTaskRequestUsingIEWSClient } catch (Exception ex) { Console.Write(ex.Message); } }
public static void Run() { // ExStart:ReadMessageByPreservingTNEFAttachments // The path to the File directory. string dataDir = RunExamples.GetDataDir_Email(); MsgLoadOptions options = new MsgLoadOptions(); options.PreserveTnefAttachments = true; MailMessage eml = MailMessage.Load(dataDir + "EmbeddedImage1.msg", options); foreach (Attachment attachment in eml.Attachments) { Console.WriteLine(attachment.Name); } // ExEnd:ReadMessageByPreservingTNEFAttachments }