HOWTO: Programmatically Find the Default MAPI Profile

Last reviewed: February 3, 1998
Article 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 : EMAPI
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.