HOWTO: Programmatically Find the Default MAPI Profile

ID: Q180233


The information in this article applies to:
  • Extended Messaging Application Programming Interface (MAPI), version 1.0


SUMMARY

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


MORE INFORMATION

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;
          } 


Additional query words: Default Profile MAPILogonEx

Keywords : kbMsg kbMAPI100
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.