Microsoft KB Archive/180233

= How To Programmatically Find the Default MAPI Profile =

Article ID: 180233

Article Last Modified on 8/18/2005

-

APPLIES TO


 * Microsoft Messaging Application Programming Interface

-



This article was previously published under Q180233



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
 Call the MAPIAdminProfiles function to retrieve an IprofAdmin interface pointer. 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. Create a restriction on the table where PR_DEFAULT_PROFILE = TRUE and call FindRow to execute restriction.  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: kbhowto kbmsg kbcode KB180233

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.