0

I am looking for a way to apply same actions on multiple Items, example Messages with a single call. Example, I retrieve a set of Messages using a search filter. After this I would want to delete the messages that matched the criteria. Currently, I iterate and call the delete() call on each item. Is there a way to call delete on the whole collection in order to optimize the number of calls?

I saw that EWS has this support but was not able to find an equivalent on the (awesome) Exchangelib.

https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-process-email-messages-in-batches-by-using-ews-in-exchange

codeoverflow
  • 71
  • 1
  • 5

1 Answers1

0

Have a look at the bulk operations documented at https://ecederstrand.github.io/exchangelib/#bulk-operations

Specifically, you can delete all items found by a query with:

a.inbox.filter(subject__startswith='something').delete()
Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63