none
Outlook 2013 VSTO Addin store configuration RRS feed

  • Question

  • Hey,

    I'm implementing an Outlook addin for Office 2013 with VS2013 and C#, I want to store some custom configuration (without Active Directory) , Could you please recommand the best way to do  that,


    Any help is appreciated 

    thanks and regards,

     


    • Moved by CoolDadTx Wednesday, November 18, 2015 3:44 PM Office related
    Wednesday, November 18, 2015 3:42 PM

Answers

  • Call Application.Session.GetDefaultFolder(olFolderInbox) to open the Inbox folder, then call MAPIFolder.GetStorage("IPM.Note.MyAddinSettings", olIdentifyByMessageClass)

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by Saharian Friday, November 20, 2015 8:47 AM
    Thursday, November 19, 2015 3:20 PM

All replies

  • MAPIFolder.GetStorage was designed to do that. You can store your custom settings in, for example, the Inbox folder. See https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getstorage.aspx 

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, November 18, 2015 5:22 PM
  • Hello,

    Thank you Dimitry for your solution and clear explanation.
    just a question, the below code allow to create a temporary user proprety (called when create New Mail ==> Send button), Could you please  advise in which MAPIFolder class level I can create a permanent user property?

    thanks and regards,


            public void SetStorage(Outlook.MailItem mailItem)
            {
                Outlook.Inspector currInsp = null;
                //Outlook.MailItem mail = null;
                Outlook.UserProperties itemProps = null;
                Outlook.UserProperty newProp = null;
    
                try
                {
                    if (mailItem is Outlook.MailItem)
                    {
                        itemProps = mailItem.UserProperties;
                        newProp = itemProps.Find("CustomProperty");
                        if (newProp != null)
                        {
                            newProp.Value = "Custom Value";
                        }
                        else
                        {
                            newProp = itemProps.Add("CustomProperty",
                                Outlook.OlUserPropertyType.olText, true);
                        }
    
                        newProp.Value = "Custom Value";
                        mailItem.Save();
    
                    }
                }
                finally
                {
                    if (newProp != null) Marshal.ReleaseComObject(newProp);
                    if (itemProps != null) Marshal.ReleaseComObject(itemProps);
                    //if (mail != null) Marshal.ReleaseComObject(mail);
                }
    
            }

    Regards,



    • Edited by Saharian Thursday, November 19, 2015 9:36 AM
    Thursday, November 19, 2015 9:31 AM
  • You can create your custom properties in the Inbox folder returned by Applicaation.Sesssion.GetDefaultFolder(olFolderInbvox).

    What exactly are you storing? Some global add-in settings?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, November 19, 2015 2:21 PM
  • Hello,

    I'm trying to  save a flag in which the user could turn on or off the addin (via check box control):
    in case of the Addin is activated, the user could save a  list of email addresses  via text fields located in the ribbon.

    thank you and Best regards,
    Thursday, November 19, 2015 2:48 PM
  • Yeo, a hidden (associated) message in the Inbox folder would be perfect for that. Look at some of the settings stored by Outlook there - use OutlookSpy and go to the Inbox folder, click IMAPIFolder button, go to the "Associated Contents" tab.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, November 19, 2015 3:06 PM
  • Hello,

    Could I do that programmatically, if so, could you please provide a link or code snippet?

    Thank you so much for you assistance :)

    Thursday, November 19, 2015 3:15 PM
  • Call Application.Session.GetDefaultFolder(olFolderInbox) to open the Inbox folder, then call MAPIFolder.GetStorage("IPM.Note.MyAddinSettings", olIdentifyByMessageClass)

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by Saharian Friday, November 20, 2015 8:47 AM
    Thursday, November 19, 2015 3:20 PM