tags:

views:

69

answers:

1

Hi,

I'm trying to retrieve an outlook (2007) folder using something like this:

Outlook.NameSpace MAPINameSpace = Application.GetNamespace("MAPI");
string storeID = MAPINameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).StoreID;
Outlook.MAPIFolder folder = MAPINameSpace.GetItemFromID(folderID, storeID);

I get an exception: "Could not open the item. Try again.".

I've tried not including storeID, passing null, passing Type.Missing -- none of them work. I've confirmed that the folderID and storeID are valid... With the exception message being as helpful as it is -- can anyone suggest a way to diagnose this?

Thanks!

A: 

Pff! I ended up putting all the folders in a Dictionary<> using the folder ID as the key. Doesn't seem noticeably slow, for a few hundred folders.

Jimmy