python 操作outlook

2023-01-31 05:01:41 python outlook 操作
# -*- coding: utf-8 -*-




from win32com.client import constants
from win32com.client.gencache import EnsuRedispatch as Dispatch




outlook = Dispatch("Outlook.Application")
mapi = outlook.GetNamespace("MAPI")




print mapi.GetDefaultFolder(6)




class Oli():
    def __init__(self, outlook_object):
        self._obj = outlook_object




    def items(self):
        array_size = self._obj.Count
        for item_index in xrange(1,array_size+1):
            yield (item_index, self._obj[item_index])




    def prop(self):
        return sorted( self._obj._prop_map_get_.keys() )




for inx, folder in Oli(mapi.Folders).items():
    # iterate all Outlook folders (top level)
    print folder.Name
    print "|----------|"
    for inx,subfolder in Oli(folder.Folders).items():        
        print "(%i)" % inx, subfolder.Name,"=> ", type(subfolder)



Outlook api 参考:
https://msdn.microsoft.com/en-us/library/office/aa155717(v=office.10).aspx

Http://www.snb-vba.eu/VBA_Outlook_external_en.html   主要的接口定义 在这里面,找了好多地方都无法查到的东西

相关文章