'How to read email messages from outlook inbox sub folder
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items
message = messages.GetFirst()
body_content = message.body
print body_content
I have an outlook email account. The inbox has a sub folder : calls I want to read email messages from this sub folder in python i am using win32com.client here is what i am doing. I can access inbox but not sub folder in that
Solution 1:[1]
You could try to traverse the list of folders in Inbox, like this:
inbox = outlook.GetDefaultFolder(6).Folders.Item("Your_Folder_Name")
For more information, please refer to this link:
Solution 2:[2]
you may use the following :
inbox = outlook.GetDefaultFolder(6).Folders['sub_folder_name']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alina Li |
| Solution 2 | Rahul Vaidya |
