Answer the question
In order to leave comments, you need to log in
How to get all the items in the Inbox folder and all its subfolders in Exchangelib?
How can I search for messages in the inbox and all subfolders without going through all the folders? The option below with reading all the folders separately in turn is not suitable.
my_folder = account.inbox / 'myfolder'
for i in my_folder.all():
print(i.subject)
from exchangelib.folders import Messages
for f in account.folders[Message]:
for i in f.filter(datetime_received__gt=emails_since):
print(i)
File "test.py", line 27, in getitem
for f in self.account.folders[Messages]:
AttributeError: 'Account' object has no attribute 'folders'
def getitem(self,c): # Вернет количество последних писем равное c из подпапок входящие
self.my_folder = self.account.root / 'Корневой уровень хранилища'
for f in self.my_folder.walk().filter(subject__contains='CallKeeper').order_by('-datetime_received')[:c]:
# for i in f.filter(subject__contains='a'):
print(f.subject, f.datetime_received)
FolderCollection(account=self.account, folders=[self.account.inbox, self.account.inbox / 'CallKeeper', self.account.inbox / 'folder2>']).filter(subject__contains='CallKeeper').order_by ('-datetime_received')[:c]:
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question