Search code examples
pythonoutlookoffice-automation

Why win32com doesnt show me all emails


I want to parse emails in python through the Outlook application. Running this code I get only a few of my emails.

import win32com.client
outlook = win32com.client.Dispatch('outlook.application')
mapi = outlook.GetNamespace("MAPI")  
inbox= mapi.GetDefaultFolder(6)  
messages= inbox.Items  
for i in messages:  
    message=i.subject  
    print(message)

I have tried changing the Default Folder and it happens everywhere. What have I done wrong?


Solution

  • Emails were not visible beacuse they were on the server!

    File-> Account Settings-> Account Settings...-> double click on your Exchange account-> set the Mail to keep offline slider to: All.

    Found it here !