I have this code, where I'm trying to loop through a mailbox with specified email-adresses in a list, but instead I'm getting the output of all email-adresses. When I print the counts, I get like 10 different email adresses, but not the ones I've limited to in the lists. How do I make it print only the ones from my list "emails"
from exchangelib import Credentials, Account
from collections import defaultdict
emails = ['test1@random.com','test2@random.com']
for email in emails:
credentials = Credentials('hidden@hidden.com', 'hiddenpass')
account = Account('hidden@hidden.com', credentials=credentials, autodiscover=True)
counts = defaultdict(int)
for item in account.inbox.all().order_by('-datetime_received')[:100]:
counts[item.sender.email_address] += 1
print(counts)