import codecs, win32com.client # This example dumps all outlook folders recursive # needed for converting Unicode->Ansi (in local system codepage) DecodeUnicodeString = lambda x: codecs.latin_1_encode(x)[0] def DumpFoldersRecursive(folders,indent): # Note: the com indexes start from 1 for i in range(1,folders.Count+1): folder = folders[i] print '%sFolder %d: "%s"' % ('\t'*indent,i,DecodeUnicodeString(folder.Name)) # if a folder has no subfolders, its Folders.Count will be zero, so this is safe. DumpFoldersRecursive(folder.Folders,indent+1) def DumpOutlookFolders(): # Create instance of Outlook o = win32com.client.Dispatch("Outlook.Application") # Dump all folders recursive, starting from root DumpFoldersRecursive(o.GetNamespace("MAPI").Folders,0) o = None DumpOutlookFolders()