Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Microsoft.Office.Interop.Outlook.Application app = null;
- Microsoft.Office.Interop.Outlook._NameSpace ns = null;
- private void button1_Click(object sender, EventArgs e)
- {
- app = new Microsoft.Office.Interop.Outlook.Application();
- ns = app.GetNamespace("MAPI");
- MessageBox.Show(countRootFolders().ToString());
- }
- public int countRootFolders()
- {
- Microsoft.Office.Interop.Outlook.MAPIFolder rootFolder = this.ns.Session.DefaultStore.GetRootFolder();
- int rootCount = rootFolder.Folders.Count;
- foreach (Microsoft.Office.Interop.Outlook.MAPIFolder subfolder in rootFolder.Folders)
- {
- rootCount += subfolder.Folders.Count;
- }
- return rootCount;
- }
- public int countRootFolders(Microsoft.Office.Interop.Outlook.MAPIFolder aFolder)
- {
- int rootCount = aFolder.Folders.Count;
- foreach (Microsoft.Office.Interop.Outlook.MAPIFolder subfolder in aFolder.Folders)
- {
- rootCount += countRootFolders( subFolder );
- }
- return rootCount;
- }
Advertisement
Add Comment
Please, Sign In to add comment