简体   繁体   English

如何过滤收件箱并仅下载带有附件的电子邮件

[英]How do I filter inbox and only download emails that have attachments

I am filtering a fairly large inbox using exchangelib. 我正在使用exchangelib过滤相当大的收件箱。 I only want to look at emails that have attachments. 我只想查看带有附件的电子邮件。

I tried to add the attachments=True clause in the filter but it does not work. 我试图在过滤器中添加attachments = True子句,但它不起作用。 Below is my code. 下面是我的代码。 Could someone tell me what is the correct way of doing this? 有人可以告诉我这样做的正确方法是什么?

account.inbox.filter(datetime_received__range=(start_time, end_time), sender=some_sender, attachments=True)

You probably want to filter on the has_attachments filter instead. 您可能希望改为使用has_attachments过滤器。 I don't think you can filter directly on an attachment. 我认为您无法直接过滤附件。 Also, you may want to only select the fields that you need, using .only() : 另外,您可能只想使用.only()选择所需的字段:

account.inbox.filter(
    datetime_received__range=(start_time, end_time),
    sender=some_sender,
    has_attachments=True,
).only('sender', 'subject', 'attachments')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Outlook 2013中未读的电子邮件中下载附件? - How do I download attachments from unread emails in Outlook 2013? 如何从使用 Python 作为附件发送的电子邮件中下载附件? - How can I download attachments from emails sent as attachments with Python? 如何从Gmail下载包含附件的所有电子邮件? - How can I download all emails with attachments from Gmail? 如何仅从特定Gmail邮件标签下载未读附件? - How do I download only unread attachments from a specific gmail label? 如何在Poplib中仅搜索包含附件的电子邮件 - How to search for only emails containing attachments in poplib 您如何访问gmail收件箱并使用python管理电子邮件? - How do you accsess to a gmail inbox and manage emails using python? 使用IMAP的Python我如何从给定日期和时间到给定主题直到现在从收件箱中读取电子邮件 - Python using IMAP how do I read emails from inbox from a given date and time until now with a given subject Python 脚本不会下载带有附件的 HTML 电子邮件 - Python script wont download HTML emails with attachments 如何使用ExchangeLib过滤掉或跳过收件箱中的会议响应? 目前正在获取AttributeError - How do I filter out or skip meeting responses in my inbox using ExchangeLib? Currently getting AttributeError 如何过滤 Numpy 数组以使每个 X 值只有一个 Y 值 - How Do I Filter a Numpy Array to Have Only One Y Value per X Value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM