O. Schultz
O. Schultz

Reputation: 175

Read out subfolder of inbox using exchangelib

is it possible to read out the body of an email that is in a subfolder of the inbox using exchangelib? If yes, how can I achieve that? I only know that I can get the body of an email which is in the inbox using the following code:

for item in account.inbox.all().order_by('-datetime_received')[:1]:
    print(item.body)

Upvotes: 1

Views: 1346

Answers (1)

Erik Cederstrand
Erik Cederstrand

Reputation: 10245

Yes, that's possible. See the folder navigation options described in https://github.com/ecederstrand/exchangelib#folders

Here's an example:

sub_sub_folder = account.inbox / 'Some' / 'Subfolder'
for item in sub_sub_folder.all().order_by('-datetime_received')[:1]:
    print(item.body)

Upvotes: 1

Related Questions