How to use StorageItem to save vsto add-in data

I am developing a VSTO add-in for Outlook in C #. I would like to be able to store some additional data, which are complex user-defined types. I went through the MSDN StorageItem API document , but not much help. Is StorageItem using the right approach? Any code examples will help.

+4
source share
1 answer

Since the solution store is created as hidden items in a folder, you can only store data if the storage provider supports hidden items and the client has write permissions to this folder.

private string GetWorkHoursXML()
{
   try
   {
        Outlook.StorageItem storage =
        Application.Session.GetDefaultFolder(
        Outlook.OlDefaultFolders.olFolderCalendar).GetStorage(
        "IPM.Configuration.WorkHours",
        Outlook.OlStorageIdentifierType.olIdentifyByMessageClass);
        Outlook.PropertyAccessor pa = storage.PropertyAccessor;
        // PropertyAccessor will return a byte array for this property
        byte[] rawXmlBytes = (byte[])pa.GetProperty(
        "http://schemas.microsoft.com/mapi/proptag/0x7C080102");
        // Use Encoding to convert the array to a string
        return System.Text.Encoding.ASCII.GetString(rawXmlBytes);
    }
    catch
    {
        return string.Empty;
    }
 }

See How to store decision-specific data as a hidden message in a folder for more information.

+1
source

All Articles