Microsoft KB Archive/236455

= PRB: MAPI_E_NOT_FOUND Retrieving Global Profile Section Properties =

Article ID: 236455

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Windows 95
 * Microsoft Windows 98 Standard Edition
 * Microsoft Outlook 98 Standard Edition
 * Microsoft Messaging Application Programming Interface

-



This article was previously published under Q236455



SYMPTOMS
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



CAUSE
The profile name used contains a space (for example "Default User").



RESOLUTION
The possible workarounds are:

Modify profile name to remove the space.Call MAPILogonEx to logon to the profile first.Install Microsoft Outlook 2000 to update the MAPI dlls.



Steps to Reproduce Behavior
 Create a profile named "Default User".  Run the following code. #include   #include    #include    #include    #include 

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

You will see that HrGetOneProp on PR_PROFILE_HOME_SERVER returns the following error message:

-2147221233 (MAPI_E_NOT_FOUND)

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:
 * edkguid.lib
 * msvcrt.lib
 * edkutils.lib
 * edkdebug.lib
 * edkmapi.lib
 * mapi32.lib
 * user32.lib
 * kernel32.lib

<div class="references_section">