I'm having the following problem to get the emails. Also, I want to filter emails by email_address domain.
Code:
from exchangelib import Q
from exchangelib import Account, Configuration, Credentials, DELEGATE, errors
...
account = connect(SERVER_URL, EMAIL, PASSWORD)
# Get the folder object
folder = account.root / 'Top of Information Store' / 'Inbox'
# Get emails
q = (Q(subject__contains='key_word') and Q(sender__contains='mydomain1.com'))
emails = folder.all().filter(q)
for item in emails:
print(item.subject)
Output:
(Nothing Prints)