Clearly documented reading of emails functionality with python win32com outlook

前端 未结 5 853
梦谈多话
梦谈多话 2020-12-12 09:27

I\'m trying to understand outlook interaction through win32com better. I\'ve been unable to find clear documentation that allows me to utilise win32com to read emails effec

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 10:00

    For everyone wondering how to reach any default folder not just "Inbox" here's the list:

    3  Deleted Items
    4  Outbox
    5  Sent Items
    6  Inbox
    9  Calendar
    10 Contacts
    11 Journal
    12 Notes
    13 Tasks
    14 Drafts
    

    There are more (Reminders, Sync errors etc.); you can get whole list with this code (inspired by John Cook's solution to Folders):

    import win32com
    outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
    for i in range(50):
        try:
            box = outlook.GetDefaultFolder(i)
            name = box.Name
            print(i, name)
        except:
            pass
    

    I'm not pasting the whole list here, because mine is in Polish and wouldn't be really helpful.

提交回复
热议问题