PRB: MAPI_E_NOT_FOUND Retrieving Global Profile Section PropertiesID: Q236455
|
When you access Global Profile Section properties using extended MAPI on a Windows 95 or Windows 98 computer with Microsoft Outlook 98 installed, you may get the following error:
MAPI_E_NOT_FOUND
The profile name used contains a space (for example "Default User").
The possible workarounds are:
#include <mapix.h>
#include <mapidefs.h>
#include <mapiguid.h>
#include <edk.h>
#include <edkmdb.h>
HRESULT GetServerName();
void main()
{
GetServerName();
}
HRESULT GetServerName()
{
HRESULT hRes = S_OK;
LPPROFADMIN pAdminProfiles = NULL;
LPSERVICEADMIN pSvcAdmin = NULL;
LPPROFSECT pGlobalProfSect = NULL;
LPSPropValue pProps = NULL;
char szServerName[256];
// initialize the MAPI subsystem,
if ( FAILED ( hRes = MAPIInitialize ( NULL ) ) )
return hRes;
// Get a Profile admin object
if ( FAILED ( hRes = MAPIAdminProfiles ( 0L, &pAdminProfiles ) ) )
goto CleanUp;
// Get a ServiceAdmin object
if ( FAILED ( hRes = pAdminProfiles -> AdminServices (
"Default User",
NULL,
0L,
0L,
&pSvcAdmin ) ) )
goto CleanUp;
// Get the Global Profile Section
if ( FAILED ( hRes = pSvcAdmin -> OpenProfileSection (
(LPMAPIUID)pbGlobalProfileSectionGuid,
NULL,
0L,
&pGlobalProfSect ) ) )
goto CleanUp;
// Call HrGetOneProp to get PR_PROFILE_HOME_SERVER
if ( FAILED ( hRes = HrGetOneProp ( pGlobalProfSect,
PR_PROFILE_HOME_SERVER,
&pProps ) ) )
goto CleanUp;
strcpy ( szServerName, "PR_PROFILE_HOME_SERVER == " );
strcat ( szServerName, pProps -> Value.lpszA );
// Replace window handle param with your application's window handle
MessageBox ( 0L, szServerName, "Exchange Server Name", MB_OK );
CleanUp:
// Free all memory allocated by any MAPI calls
if ( NULL != pAdminProfiles )
pAdminProfiles -> Release ();
if ( NULL != pSvcAdmin )
pSvcAdmin -> Release ( );
if ( NULL != pGlobalProfSect )
pGlobalProfSect -> Release ( );
if ( NULL != pProps )
MAPIFreeBuffer ( &pProps );
pSvcAdmin = NULL;
pGlobalProfSect = NULL;
pProps = NULL;
pAdminProfiles = NULL;
// Return the HRESULT to the calling function
return hRes;
}
NOTE: This code sample needs to be compiled using the "Ignore all default libraries" option on the Link tab of the Project Settings dialog box. The following libraries must also be used:-2147221233 (MAPI_E_NOT_FOUND)
For additional information about how to open the Global Profile Section and retrieve properties that exist in this section, please see the following article in the Microsoft Knowledge Base:
Q188482 HOWTO: Open the Global Profile Section
Additional query words: Profile Space
Keywords : kbMAPI kbMsg kbOutlook98 kbVC kbWinOS95 kbWinOS98 kbMAPI100 kbGrpMsg kbDSupport
Version : WINDOWS:1.0,95,98
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: July 21, 1999