IARP

Python 3 accessing win32com.client.constants

Originally Written: 2016-03-01

After installing the relevent installation of pywin32 you will be able to start accessing win32com items.

I will show you an example for accessing Outlook from Python.

According to Microsofts documentation here after you’ve set a variable with the NameSpace object, if you want to get the default folder in outlook for certain things like Inbox, Trash, Sent, Deleted…etc. What you do is call .GetDefaultFolder(olFolderInbox) and that will return the default Inbox folder in the Outlook you are connecting to.

Python doesn’t know what olFolderInbox is by default, it’s just another variable that is undefined yet. win32com gives you access to these constants by going to win32com.client.constants.WhatEverYouNeed. By default though win32com does not make these constants, you need to run another application.

You will now be able to access win32com.client.constants.olFolderInbox