public static void Run()
        {
            // ExStart:RenderingContactInformationToMhtml
            string dataDir = RunExamples.GetDataDir_Outlook();

            //Load VCF Contact and convert to MailMessage for rendering to MHTML
            MapiContact contact = MapiContact.FromVCard(dataDir + "Contact.vcf");

            MemoryStream ms = new MemoryStream();

            contact.Save(ms, ContactSaveFormat.Msg);
            ms.Position = 0;
            MapiMessage           msg = MapiMessage.FromStream(ms);
            MailConversionOptions op  = new MailConversionOptions();
            MailMessage           eml = msg.ToMailMessage(op);

            //Prepare the MHT format options
            MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();

            mhtSaveOptions.CheckBodyContentEncoding   = true;
            mhtSaveOptions.PreserveOriginalBoundaries = true;
            MhtFormatOptions formatOp = MhtFormatOptions.WriteHeader | MhtFormatOptions.RenderVCardInfo;

            mhtSaveOptions.RenderedContactFields = ContactFieldsSet.NameInfo | ContactFieldsSet.PersonalInfo | ContactFieldsSet.Telephones | ContactFieldsSet.Events;
            mhtSaveOptions.MhtFormatOptions      = formatOp;
            eml.Save(dataDir + "ContactMhtml_out.mhtml", mhtSaveOptions);
            // ExEnd:RenderingContactInformationToMhtml
        }
        public static void Run()
        {
            try
            {

                // ExStart: SendCalendarInvitation
                using (IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"))
                {
                    // delegate calendar access permission
                    ExchangeDelegateUser delegateUser = new ExchangeDelegateUser("*****@*****.**", ExchangeDelegateFolderPermissionLevel.NotSpecified);
                    delegateUser.FolderPermissions.CalendarFolderPermissionLevel = ExchangeDelegateFolderPermissionLevel.Reviewer;
                    client.DelegateAccess(delegateUser, "*****@*****.**");

                    // Create invitation
                    MapiMessage mapiMessage = client.CreateCalendarSharingInvitationMessage("*****@*****.**");
                    MailConversionOptions options = new MailConversionOptions();
                    options.ConvertAsTnef = true;
                    MailMessage mail = mapiMessage.ToMailMessage(options);
                    client.Send(mail);
                }
                // ExEnd: SendCalendarInvitation

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run()
        {
            try
            {
                // ExStart: SendCalendarInvitation
                using (IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"))
                {
                    // delegate calendar access permission
                    ExchangeDelegateUser delegateUser = new ExchangeDelegateUser("*****@*****.**", ExchangeDelegateFolderPermissionLevel.NotSpecified);
                    delegateUser.FolderPermissions.CalendarFolderPermissionLevel = ExchangeDelegateFolderPermissionLevel.Reviewer;
                    client.DelegateAccess(delegateUser, "*****@*****.**");

                    // Create invitation
                    MapiMessage           mapiMessage = client.CreateCalendarSharingInvitationMessage("*****@*****.**");
                    MailConversionOptions options     = new MailConversionOptions();
                    options.ConvertAsTnef = true;
                    MailMessage mail = mapiMessage.ToMailMessage(options);
                    client.Send(mail);
                }
                // ExEnd: SendCalendarInvitation
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 public static void Run()
 {
     //ExStart:ConvertMSGToMIMEMessage
     MapiMessage msg = new MapiMessage("*****@*****.**","[email protected]; [email protected]","Test Subject","This is a body of message.");
     var options = new MailConversionOptions();
     options.ConvertAsTnef = true;
     MailMessage mail = msg.ToMailMessage(options);
     //ExEnd:ConvertMSGToMIMEMessage
 }
 public static void Run()
 {
     // ExStart:CreatingTNEFFromMSG
     // The path to the File directory.
     string dataDir = RunExamples.GetDataDir_Email();
     MapiMessage msg = MapiMessage.FromFile(dataDir + "Message.msg");
     MailConversionOptions options = new MailConversionOptions {ConvertAsTnef = true};
     MailMessage mail = msg.ToMailMessage(options);           
     // ExEnd:CreatingTNEFFromMSG
 }
Example #6
0
        public static void Run()
        {
            //ExStart:ConvertMSGToMIMEMessage
            MapiMessage msg     = new MapiMessage("*****@*****.**", "[email protected]; [email protected]", "Test Subject", "This is a body of message.");
            var         options = new MailConversionOptions();

            options.ConvertAsTnef = true;
            MailMessage mail = msg.ToMailMessage(options);
            //ExEnd:ConvertMSGToMIMEMessage
        }
 public static void Run()
 {
     // ExStart:CreatingTNEFFromMSG
     // The path to the File directory.
     string                dataDir = RunExamples.GetDataDir_Email();
     MapiMessage           msg     = MapiMessage.FromFile(dataDir + "Message.msg");
     MailConversionOptions options = new MailConversionOptions {
         ConvertAsTnef = true
     };
     MailMessage mail = msg.ToMailMessage(options);
     // ExEnd:CreatingTNEFFromMSG
 }
Example #8
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Email();

            // ExStart:CreateTNEFEMLFromMSG
            MapiMessage mapiMsg = MapiMessage.FromFile(dataDir + "Message.msg");

            MailConversionOptions mco = new MailConversionOptions();

            mco.ConvertAsTnef = true;

            MailMessage message = mapiMsg.ToMailMessage(mco);
            // ExEnd:CreateTNEFEMLFromMSG
        }
        Response ConvertOstToMbox(string fileName, string folderName)
        {
            return(ProcessTask(fileName, folderName, delegate(string inputFilePath, string outputFolderPath)
            {
                using (var personalStorage = PersonalStorage.FromFile(inputFilePath))
                {
                    var options = new MailConversionOptions();

                    using (FileStream writeStream = new FileStream(Path.Combine(outputFolderPath, Path.GetFileNameWithoutExtension(inputFilePath) + ".mbox"), FileMode.Create))
                    {
                        using (MboxrdStorageWriter writer = new MboxrdStorageWriter(writeStream, false))
                        {
                            HandleFolderAndSubfolders(mapiMessage =>
                            {
                                var msg = mapiMessage.ToMailMessage(options);
                                writer.WriteMessage(msg);
                            }, personalStorage.RootFolder, options);
                        }
                    }
                }
            }));
        }
        ///<Summary>
        /// ConvertPstToMbox method to convert pst to mbox file
        ///</Summary>
        public Response ConvertPstToMbox(string fileName, string folderName)
        {
            return(ProcessTask(fileName, folderName, ".mbox", false, false, delegate(string inFilePath, string outPath, string zipOutFolder)
            {
                var options = new MailConversionOptions();

                System.IO.File.Delete(outPath);
                using (FileStream writeStream = new FileStream(outPath, FileMode.Create))
                {
                    using (MboxrdStorageWriter writer = new MboxrdStorageWriter(writeStream, false))
                    {
                        using (var pst = PersonalStorage.FromFile(inFilePath))
                        {
                            HandleFolderAndSubfolders(mapiMessage =>
                            {
                                var msg = mapiMessage.ToMailMessage(options);
                                writer.WriteMessage(msg);
                            }, pst.RootFolder, options);
                        }
                    }
                }
            }));
        }
Example #11
0
        void HandleFolderAndSubfolders(Action <MapiMessage> handler, FolderInfo folderInfo, MailConversionOptions options)
        {
            foreach (MapiMessage mapiMessage in folderInfo.EnumerateMapiMessages())
            {
                handler(mapiMessage);
            }

            if (folderInfo.HasSubFolders == true)
            {
                foreach (FolderInfo subfolderInfo in folderInfo.GetSubFolders())
                {
                    HandleFolderAndSubfolders(handler, subfolderInfo, options);
                }
            }
        }