#!/usr/bin/env python
# _*_ coding: utf-8 _*_
# @Time : 2017/5/15 9:58
# @Author : otfsenter
# @File : main.py
from win32com.client.gencache import EnsureDispatch as Dispatch
outlook = Dispatch("Outlook.Application")
mapi = outlook.GetNamespace("MAPI")
def oli(outlook_object):
for item_index in xrange(1, outlook_object.Count+1):
yield (item_index, outlook_object[item_index])
for inx, folder in oli(mapi.Folders):
print folder.Name
for inx1, subfolder in oli(folder.Folders):
print "(%i)" % inx1, subfolder.Name #, "=> ", subfolder
try:
for inx2, subfolder1 in oli(subfolder.Folders):
print " (%i)" % inx2, subfolder1.Name #, "=> ", subfolder1
except:
pass
if inx == 1:
break