HOWTO: Getting the Contents of the Exchange Global Address ListLast reviewed: January 7, 1998Article ID: Q166106 |
The information in this article applies to:
SUMMARYThis article describes the process and code for opening the Microsoft Exchange Global Address List (GAL) and then retrieving the list of recipients in it. This code is specific to Microsoft Exchange Server. Any other MAPI compliant server will have a similar process but the actual code may be different.
MORE INFORMATIONTo find the global address list:
HRESULT GetGALContents ( LPSRowSet * ppRow ) { ULONG cbeid = 0L; LPENTRYID lpeid = NULL; HRESULT hRes = S_OK; LPSRowSet pRow; ULONG ulObjType; ULONG cRows = 0L; LPMAPITABLE lpContentsTable = NULL; LPMAPICONTAINER lpGAL = NULL; SizedSPropTagArray ( 2, sptCols ) = { 2, PR_ENTRYID, PR_DISPLAY_NAME }; if ( FAILED ( hRes = HrFindExchangeGlobalAddressList ( m_pAddrBook, &cbeid, &lpeid ) ) ) goto Quit; if(FAILED(hRes = m_pAddrBook->OpenEntry((ULONG) cbeid, (LPENTRYID) lpeid, NULL, MAPI_BEST_ACCESS, &ulObjType, (LPUNKNOWN *)&lpGAL))) goto Quit; if ( ulObjType != MAPI_ABCONT ) goto Quit; if(FAILED(hRes = lpGAL->GetContentsTable(0L, &lpContentsTable))) goto Quit; if(FAILED(hRes = lpContentsTable->SetColumns((LPSPropTagArray)&sptCols, TBL_BATCH))) goto Quit; if ( FAILED ( hRes = lpContentsTable -> GetRowCount ( 0, &cRows ) ) ) goto Quit; if ( FAILED ( hRes = lpContentsTable -> QueryRows ( cRows, 0L, &pRow ) goto Quit; else *ppRow = pRow; Quit: if ( NULL != lpGAL) { lpGAL -> Release ( ); lpGAL = NULL; } if ( lpContentsTable ) { lpContentsTable -> Release ( ); lpContentsTable = NULL; } return hRes; } // End codeNOTE: In order to compile and run this code, you must have the Win32 SDK and the Platform SDK. The latest versions of these SDK's are January 1997 and March 1997, respectively. The following libraries must be included for linking: Mapi32.lib, Edkmapi.lib, Edkutils.lib, and Addrlkup.lib. If you are building in debug mode, Edkdebug.lib is also necessary. Also, the debug or release MultiThreaded DLL option must be selected in the code generation options of the C/C++ tab in the build settings dialog box in order to link properly.
REFERENCESFor more information on starting a MAPI session read the topic "Opening an Information Store" found on the January 1997 MSDN CD. Keywords : EDKAPI EMAPI Version : 1.0 Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |