Determine currently selected Outlook profile


I’m dealing with several Office installations that have two profiles, primarily in order for the Exchange connection in one profile not to break normal (caldav) based calendars in the other profile.

There are some actions that only should only be applied when a particular profile is active. I detect if Outlook is running (using psutil), and if Outlook is not running, things are easy: start outlook with the appropriate profile and then execute the actions.

However if outlook is already running, it could be that the "wrong" profile has been selected on startup. How can I use Python to query the selected profile on a already opened Outlook?

I tried to look in %APPDATA%MicrosoftOutlook (that is the one under roaming) There is a xyz.xml for the appropriate profile xyz, but it doesn’t get touched until Outlook exits. There is a file ending in .srs that gets touched immediately when Outlook opens, but there seems to be no fixed relationship with the name of the profiles (sometimes xyz.srs exists sometimes it does not).

Asked By: Anthon



If outlook.exe is already running, create an instance of the Outlook.Application COM object (Outlook is a singleton and you will get a pointer to the already running instance), and read the Application.Session.CurrentProfileName property.

Make sure your code is running in the same security context (same local user and matching security settings) – otherwise COM system will refuse to marshal the calls.

import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.