My intention is to have my code read all received emails (both read and unread and moved to other folders). With the following code I am only able to read some emails in the inbox folder but not the folders where the emails were moved after reading
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
# the inbox. You can change that number to reference
# any other folder
messages = inbox.Items
for message in messages:
body_content = message.body
print (body_content)