Aspose.Email.Examples.CSharp.Email.Outlook.ReadAndWritingOutlookTemplateFile.Run C# (CSharp) Метод

Run() публичный статический Метод

public static Run ( ) : void
Результат void
        public static void Run()
        {
            //ExStart:ReadAndWritingOutlookTemplateFile
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Load the Outlook template (OFT) file in MailMessage's instance
            MailMessage message = MailMessage.Load(dataDir + "sample.oft", new MsgLoadOptions());

            // Set the sender and recipients information
            string senderDisplayName = "John";
            string senderEmailAddress = "[email protected]";
            string recipientDisplayName = "William";
            string recipientEmailAddress = "[email protected]";

            message.Sender = new MailAddress(senderEmailAddress, senderDisplayName);
            message.To.Add(new MailAddress(recipientEmailAddress, recipientDisplayName));
            message.HtmlBody = message.HtmlBody.Replace("DisplayName", "<b>" + recipientDisplayName + "</b>");

            // Set the name, location and time in email body
            string meetingLocation = "<u>" + "Hall 1, Convention Center, New York, USA" + "</u>";
            string meetingTime = "<u>" + "Monday, June 28, 2010" + "</u>";
            message.HtmlBody = message.HtmlBody.Replace("MeetingPlace", meetingLocation);
            message.HtmlBody = message.HtmlBody.Replace("MeetingTime", meetingTime);

            // Save the message in MSG format and open in Office Outlook
            MapiMessage msg = MapiMessage.FromMailMessage(message);
            msg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);
            msg.Save(dataDir + "ReadAndWritingOutlookTemplateFile_out.msg");
            //ExEnd:ReadAndWritingOutlookTemplateFile
        }
    }
ReadAndWritingOutlookTemplateFile