How To Programmatically Find the Default MAPI Profile

Article translations Article translations
Article ID: 180233 - View products that this article applies to.
This article was previously published under Q180233
Expand all | Collapse all

On This Page


This article describes the steps needed to find the name of the default MAPI Profile for your account.


The default profile is the profile used if you do not explicitly specify one in the call to MAPILogonEx and instead set the MAPI_USE_DEFAULT flag.

Steps to Find the Default Profile

  1. Call the MAPIAdminProfiles() function to retrieve an IprofAdmin interface pointer.
  2. Call IProfAdmin::GetProfileTable() to retrieve a table of all profiles. This table has one row for every available profile. There are only two columns in each row; the profile's display name and a flag that indicates whether the profile is the default.
  3. Create a restriction on the table where PR_DEFAULT_PROFILE = TRUE and call FindRow() to execute restriction.
  4. Call QueryRows() to retrieve the row containing the default profile.

    Here is a code sample that implements the steps to find the default profile:
          HRESULT        hr;
          SRestriction   sres;
          SPropValue     spvDefaultProfile;
          LPSRowSet      pRow = NULL;
          LPSTR          lpDisplayName = NULL;
          // Get a IProfAdmin Interface.
          hr = MAPIAdminProfiles(0, &lpProfAdmin);
          LPMAPITABLE    lpProfileTable;
          // Get the Table of Profiles
          hr = lpProfAdmin->GetProfileTable(0, &lpProfileTable);
          // build a restriction where PR_DEFAULT_PROFILE = TRUE
          spvDefaultProfile.ulPropTag = PR_DEFAULT_PROFILE;
          spvDefaultProfile.Value.b = TRUE;
          sres.rt = RES_PROPERTY;
          sres.res.resProperty.relop = RELOP_EQ;
          sres.res.resProperty.ulPropTag = PR_DEFAULT_PROFILE;
          sres.res.resProperty.lpProp = &spvDefaultProfile;
          hr = lpProfileTable->Restrict(&sres, TBL_BATCH);
          hr = lpProfileTable->FindRow(&sres, BOOKMARK_BEGINNING, 0);
          // we have a match
          hr = lpProfileTable->QueryRows(1,0,&pRow);
          if (SUCCEEDED(hr))
             lpDisplayName = pRow->aRow[0].lpProps[0].Value.lpszA;


Article ID: 180233 - Last Review: August 18, 2005 - Revision: 1.5
  • Microsoft Office Outlook 2007
  • Microsoft Messaging Application Programming Interface
kbcode kbhowto kbmsg KB180233

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from