I am filtering a fairly large inbox using 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. 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. 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()
:
account.inbox.filter(
datetime_received__range=(start_time, end_time),
sender=some_sender,
has_attachments=True,
).only('sender', 'subject', 'attachments')
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments