public static void Run()
        {
            // ExStart:LoadMessageWithLoadOptions
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Email();

            // Load Eml, html, mhtml, msg and dat file
            MailMessage mailMessage = MailMessage.Load(dataDir + "Message.eml", new EmlLoadOptions());

            MailMessage.Load(dataDir + "description.html", new HtmlLoadOptions());
            MailMessage.Load(dataDir + "Message.mhtml", new MhtmlLoadOptions());
            MailMessage.Load(dataDir + "Message.msg", new MsgLoadOptions());

            // loading with custom options
            EmlLoadOptions emlLoadOptions = new EmlLoadOptions
            {
                PrefferedTextEncoding   = Encoding.UTF8,
                PreserveTnefAttachments = true
            };

            MailMessage.Load(dataDir + "description.html", emlLoadOptions);
            HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions
            {
                PrefferedTextEncoding  = Encoding.UTF8,
                ShouldAddPlainTextView = true,
                PathToResources        = dataDir
            };

            MailMessage.Load(dataDir + "description.html", emlLoadOptions);
            // ExEnd:LoadMessageWithLoadOptions
        }
Exemple #2
0
        public static void Run()
        {
            // The path to the File directory.
            string dataDir  = RunExamples.GetDataDir_Exchange();
            string dstEmail = dataDir + "Message.eml";

            // Create instance of ExchangeClient class by giving credentials
            IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

            // load task from .eml file
            EmlLoadOptions loadOptions = new EmlLoadOptions();

            loadOptions.PrefferedTextEncoding   = Encoding.UTF8;
            loadOptions.PreserveTnefAttachments = true;

            // load task from .msg file
            MailMessage eml = MailMessage.Load(dstEmail, loadOptions);

            eml.From = "*****@*****.**";
            eml.To.Clear();
            eml.To.Add(new MailAddress("*****@*****.**"));

            client.Send(eml);

            Console.WriteLine(Environment.NewLine + "Task sent on Exchange Server successfully.");
        }
        public static void Run()
        {

            try
            {

                // The path to the File directory.
                string dataDir = RunExamples.GetDataDir_Exchange();
                string dstEmail = dataDir + "Message.eml";

                // Create instance of ExchangeClient class by giving credentials
                IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

                // load task from .eml file
                EmlLoadOptions loadOptions = new EmlLoadOptions();

                loadOptions.PrefferedTextEncoding = Encoding.UTF8;
                loadOptions.PreserveTnefAttachments = true;

                // load task from .msg file
                MailMessage eml = MailMessage.Load(dstEmail, loadOptions);
                eml.From = "*****@*****.**";
                eml.To.Clear();
                eml.To.Add(new MailAddress("*****@*****.**"));
                client.Send(eml);
                Console.WriteLine(Environment.NewLine + "Task sent on Exchange Server successfully.");
            }
            catch (Exception ex)
            {

                Console.Write(ex.Message);
            }
        }
        public static void Run()
        {
            // ExStart:LoadMessageWithLoadOptions
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Email();

            // Load Eml, html, mhtml, msg and dat file 
            MailMessage mailMessage = MailMessage.Load(dataDir + "Message.eml", new EmlLoadOptions());
            MailMessage.Load(dataDir + "description.html", new HtmlLoadOptions());
            MailMessage.Load(dataDir + "Message.mhtml", new MhtmlLoadOptions());
            MailMessage.Load(dataDir + "Message.msg", new MsgLoadOptions());

            // loading with custom options
            EmlLoadOptions emlLoadOptions = new EmlLoadOptions
            {
                PrefferedTextEncoding = Encoding.UTF8,
                PreserveTnefAttachments = true
            };

            MailMessage.Load(dataDir + "description.html", emlLoadOptions);
            HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions
            {
                PrefferedTextEncoding = Encoding.UTF8,
                ShouldAddPlainTextView = true,
                PathToResources = dataDir
            };
            MailMessage.Load(dataDir + "description.html", emlLoadOptions);
            // ExEnd:LoadMessageWithLoadOptions
        }