Esempio n. 1
0
        /// <summary>
        /// Persist this object to Exchange as a StorageItem.
        /// </summary>
        public void Save()
        {
            Outlook.MAPIFolder  inboxFolder = Globals.ThisAddIn.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            Outlook.StorageItem configItem  = inboxFolder.GetStorage(Options.CONFIG_MESSAGE_SUBJECT, Outlook.OlStorageIdentifierType.olIdentifyBySubject);
            configItem.Subject = Options.CONFIG_MESSAGE_SUBJECT;

            XmlSerializer x = new XmlSerializer(typeof(Options));

            using (StringWriter writer = new StringWriter())
            {
                // serialize this object into XML and store into the config item's body property
                x.Serialize(writer, this);
                configItem.Body = writer.ToString();

                // persist the item to Exchange
                configItem.Save();

                Log.WriteEntry("User options were saved to Exchange.");
            }
        }