3

I want to read the mails from the subfolder of the outlook mailbox.

Inbox
├──myfolder

I can read Inbox using account.inbox.all() but i want to read mails in myfolder

I tried the things in folder section of this page but i couldn't get it right

https://pypi.python.org/pypi/exchangelib/

rdm_
  • 67
  • 1
  • 8

2 Answers2

4

You need to get hold of the Folder instance for myfolder first:

my_folder = account.inbox / 'myfolder'
for i in my_folder.all():
    print(i.subject)
Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63
0

Just in case if you have a lot of sub-folders (including nested ones) inside your directory and you want to print the subject of all then use this method.

folder = account.root/'Top of Information Store'/'Inbox'/folder_name
all_folders = folder.glob('**/*')
for subfolders in all_folders:
    for emails in subfolders.all():
        print(emails.subject)
AgentLog
  • 97
  • 1
  • 5