使用 Python 3.7 中的 ExchangeLib 在 Outlook 中读取自定义标签/标志

问题描述

我正在阅读 Outlook 中包含自定义标签/标志的邮件。其中一个是“已批准”标签。我正在尝试使用 python 中的 ExchangeLib 库访问来自标记为“已批准”的特定发件人的邮件。

我尝试了 ExchangeLib 库中可用的多种方法,但没有成功。我只是想在控制台中打印出这个标签“已批准”。我尝试了以下方法:

ID_ELEMENT_CLS account add_field attach attachments body categories conversation_id culture datetime_created datetime_received datetime_sent deregister detach display_cc display_to effective_rights folder has_attachments headers importance in_reply_to is_associated is_draft is_from_me is_resend is_submitted is_unmodified item_class last_modified_name last_modified_time mime_content parent_folder_id register reminder_due_by reminder_is_set reminder_minutes_before_start remove_field response_objects sensitivity size subject supported_fields text_body unique_body validate_field web_client_edit_form_query_string web_client_read_form_query_string

Python - 3.7 Exchangelib - 3.3.2

Image "Customized_Tags" contains "Approved" Tag

参考下面的代码快照:

from exchangelib import Credentials,Account

credentials = Credentials('john@example.com','topsecret')
account = Account('john@example.com',credentials=credentials,autodiscover=True)
for item in account.inbox.all().order_by('-datetime_received')[:100]:
    #below is my requirement
    if item.tag == "Approved":
        print(item.tag,item.sender)
    else:
         pass

解决方法

标志是 Exchange 中所谓的扩展属性。 https://ecederstrand.github.io/exchangelib/#extended-properties

提供了有关在 exchangelib 中使用扩展属性的信息

您必须找到代表包含标志数据的扩展属性的魔术令牌,然后在 exhcangelib 中定义一个自定义字段并将其注册为名为 tag 的新字段。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...