iterating folder collection

  • Thread starter Thread starter Anushya
  • Start date Start date
A

Anushya

Hi

when i try to browse thru all the folders in outlook recursively
starting from the root folder, i couldnot explore the USER FOLDERS
which comes straight under root folder.

Wot is the problem,
1)i am using folders(1) as the root folder??
2)Or the user folders created under root folder will not come under
root folder while exploring???

see my edited code below

IterateFolder(oNs.Folders[1]);

public static void IterateFolder(Microsoft.Office.Interop.Outlook.MAPIFolder
oFldr)
{
for(int intL = 1;intL <= oFldr.Folders.Count;intL++)
IterateFolder(oFldr.Folders[intL]);
}

Thanks
Anushya
 
There's no way to know for certain what folders(1) is. If you want to
iterate all folders, you should iterate all members of the oNs.Folders
collection. If you want to iterate only the user's default store, use
Namespace.GetDefaultFolder to return the Inbox, then get the Inbox folder's
Parent and start your iteration from that folder's Folders collection.
 
Thanks Sue. It works
Microsoft.Office.Interop.Outlook.MAPIFolder oOlInboxFolder =
oOutlookNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

IterateFolder((Microsoft.Office.Interop.Outlook.MAPIFolder)oOlInboxFolder.Parent);
Anushya
Sue Mosher said:
There's no way to know for certain what folders(1) is. If you want to
iterate all folders, you should iterate all members of the oNs.Folders
collection. If you want to iterate only the user's default store, use
Namespace.GetDefaultFolder to return the Inbox, then get the Inbox folder's
Parent and start your iteration from that folder's Folders collection.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Anushya said:
Hi

when i try to browse thru all the folders in outlook recursively
starting from the root folder, i couldnot explore the USER FOLDERS
which comes straight under root folder.

Wot is the problem,
1)i am using folders(1) as the root folder??
2)Or the user folders created under root folder will not come under
root folder while exploring???

see my edited code below

IterateFolder(oNs.Folders[1]);

public static void IterateFolder(Microsoft.Office.Interop.Outlook.MAPIFolder
oFldr)
{
for(int intL = 1;intL <= oFldr.Folders.Count;intL++)
IterateFolder(oFldr.Folders[intL]);
}

Thanks
Anushya
 
Back
Top