tags:

views:

1940

answers:

2

Hi Everybody,

I'm trying to write some C# code to get 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 get me to to the "Inbox" folder. I'm trying to get to a folder at the same level as the Inbox folder. I believe I need to use GetFolderFromID instead of GetSharedDefaultFolder, but I don't understand how to use it. Is there a way to iterate through all the top level folders? How might I determine the EntryID and StoreID of the folder?

Thanks!

+2  A: 

You can use the Folders collection member of the Outlook.NameSpace object. That way you can iterate through the collection and find your folder by it's name. In case you still want to use GetFolderFromID, you can use OutlookSpy tool to get the EntryID and StoreID values.

Alejandro Bologna
A: 

i m not finding any folder collection member in Outlook.Namespace Object,... is there any way to get the folder by folder-name , i m using c#