How To Programmatically Find the Default MAPI Profile

This article has been archived. It is offered "as is" and will no longer be updated.
This article describes the steps needed to find the name of the defaultMAPI Profile for your account.
More information
The default profile is the profile used if you do not explicitly specifyone 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;      }						
Default Profile MAPILogonEx

Article ID: 180233 - Last Review: 01/11/2015 01:42:35 - Revision: 2.0

Microsoft Office Outlook 2007, Microsoft Messaging Application Programming Interface

  • kbnosurvey kbarchive kbcode kbhowto kbmsg KB180233