habeeba
habeeba

Reputation: 11

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

Upvotes: 0

Views: 5867

Answers (2)

Rahul Vaidya
Rahul Vaidya

Reputation: 319

you may use the following :

inbox = outlook.GetDefaultFolder(6).Folders['sub_folder_name']

Upvotes: 0

Alina Li
Alina Li

Reputation: 884

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:

How to access a subfolder in Outlook inbox in Python

Upvotes: 2

Related Questions