[英]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.