0
votes
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

1
Welcome to StackOverflow, please see How to Ask and help center to properly format your question to a specific one with an minimal reproducible example.r.ook
I recommend using POP/IMAP for this. If you don't know what that is, read up on the subject (before you go pywin32)Torxed
i am using win32com.client here is what i am doing. I can access inbox but not sub folder in thathabeeba

1 Answers

2
votes

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