COMException (0x80040102) when trying to access autocomplete stream

0

I'd like to access the autocomplete (nickname) stream in Outlook 2013, so that I could let user pick email address from a list.

I tried appropriating this VB code I found, however when I run this version, it throws an exception.

public byte[] GetAutocompleteBytes()
{
     Outlook.NameSpace n = ApplicationGlobal.GetNamespace("MAPI");
     Outlook.MAPIFolder f = n.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
     Outlook.StorageItem si = f.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass);
     Outlook.PropertyAccessor pa = si.PropertyAccessor;
     byte[] autocompletebytes = (byte[])pa.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x7C090102");
     return autocompletebytes;
}

The exception is "System.Runtime.InteropServices.COMException (0x80040102) - Cannot create storage item in this folder. Either the folder is read only, or storage item is not allowed here" (but in my language, so forgive inaccuracies). I could not find anything that would seem relatable about this exception. It gets thrown right when f.GetStorage() gets called, and I am really confused, since I can see the storage item in OutlookSpy, and the creator of the code seemed sure it would work. I've read through Microsoft Documentation and few other sources, but found nothing that would help me resolve this. What am I missing?

c#
outlook
vsto
asked on Stack Overflow Sep 1, 2020 by Vojtech Radom • edited Sep 1, 2020 by Vojtech Radom

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0