Finding a Profile Name

Applies to: Outlook 2013 | Outlook 2016

Clients sometimes need to find the name of the profile currently being used for the session, the name of the default profile, or the name of an alternate profile installed on the computer.

There are a few ways to retrieve the name of a profile during the course of a session. If you need to find the name of a profile that is not necessarily the one being used for the session, use the first procedure. If you need to find the name of the default profile, use the second procedure. If you need to find the name of the current profile for the session, use the last procedure.

To find the name of any profile

  1. Call MAPIAdminProfiles to retrieve an IProfAdmin interface pointer.

  2. Call IProfAdmin::GetProfileTable to access the profile table.

  3. Call the profile table's IMAPITable::QueryRows method to retrieve all of the rows in the table and examine each one to determine if it represents your target profile.

To find the name of the default profile

  1. Call MAPIAdminProfiles.

  2. Call IProfAdmin::GetProfileTable to access the profile table.

  3. Build a property restriction with an SPropertyRestriction structure to match PR_DEFAULT_PROFILE (PidTagDefaultProfile) with the value TRUE.

  4. Call IMAPITable::FindRow to locate the row in the profile table that represents the default profile. The PR_DISPLAY_NAME (PidTagDisplayName) column contains the name of the default profile.

To find the name of the current profile

To find the name of the current profile, complete one of the following steps:

  • Assuming that you have the MAPIUID structure representing one of the current profile's sections, pass it in the lpUID parameter to IMAPISession::OpenProfileSection. Retrieve the profile section's PR_PROFILE_NAME (PidTagProfileName) property using its IMAPIProp::GetProps method.

  • Call IMAPISession::GetStatusTable to access the status table and find the row that has its PR_RESOURCE_TYPE (PidTagResourceType) column set to MAPI_SUBSYSTEM. The PR_DISPLAY_NAME column for this row is the profile name. Do not use the status table during start up because it blocks an application until the MAPI spooler has finished initializing all of the transport providers. This can degrade your performance.