【问题标题】:Read emails shifted to other folders outook阅读电子邮件转移到其他文件夹 Outlook
【发布时间】:2021-12-21 23:04:17
【问题描述】:

我的目的是让我的代码读取所有收到的电子邮件(已读和未读以及移动到其他文件夹)。使用以下代码,我只能阅读收件箱文件夹中的一些电子邮件,但不能阅读阅读后移动电子邮件的文件夹

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
                                    # the inbox. You can change that number to reference
                                    # any other folder
messages = inbox.Items
for message in messages:
    body_content = message.body
    print (body_content)

【问题讨论】:

标签: python outlook pywin32 win32com


【解决方案1】:

使用MAPIFolder.Folders 集合。如果相关文件夹是收件箱文件夹的子文件夹,请使用

subFolder = inbox.Folders.Item("Sub folder name")

如果它与收件箱本身处于同一级别,请使用类似

subFolder = inbox.Parent.Folders.Item("Sub folder name")

【讨论】:

    猜你喜欢
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    • 2017-09-05
    • 2018-07-08
    • 1970-01-01
    相关资源
    最近更新 更多