Using Outlook API to access a specific folder

I am trying to write C # code to navigate to a specific folder in an Outlook mailbox. I have the following code:

Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
Outlook.Recipient oRecip = oNS.CreateRecipient("AccountNameHere");
oRecip.Resolve();
if (oRecip.Resolved)
{
  oInbox = oNS.GetSharedDefaultFolder(oRecip, Outlook.OlDefaultFolders.olFolderInbox);
  oInboxMsgs = oInbox.Items;
  ItemCount = oInboxMsgs.Count;
  Console.Writeline("There are {0] items.", ItemCount.ToString())
}

This will bring me to the inbox. I am trying to reach the folder at the same level as the inbox. I believe that I need to use GetFolderFromID instead of GetSharedDefaultFolder, but I do not understand how to use it. Is there a way to iterate over all the top-level folders? How to determine EntryID and StoreID in a folder?

Thank!

+3
source share
1 answer

Outlook.NameSpace. , . GetFolderFromID, OutlookSpy, EntryID StoreID.

+5

Source: https://habr.com/ru/post/1696995/


All Articles