|
-
September 20th, 1999, 02:26 AM
#1
Read Addressbok from Exchange server
How do I do to read the addressbook from an Exchange server ?
Please show me some samplecode!
-
March 25th, 2000, 05:21 AM
#2
Re: Read Addressbok from Exchange server
Dear friend
I have just finished a assignment on this.
Please try this code.
My mail-id is
[email protected]
void MyFunc()
{
LPMAPISESSION pSession = NULL;
HRESULT hRes = 0;
LPADRBOOK lpAddrBook = NULL;
LPMAPIPROP lpGal = NULL;
LPMAPITABLE pTable = NULL;
BOOL bContinue = FALSE;
hRes = MAPIInitialize(NULL);
hRes = MAPILogonEx(0,NULL,NULL,MAPI_NEW_SESSION | MAPI_EXPLICIT_PROFILE | MAPI_ALLOW_OTHERS |MAPI_LOGON_UI,&pSession );
//The IMAPISession::OpenAddressBook method opens the MAPI integrated
address book, returning an IAddrBook pointer for further access.
hRes = pSession->OpenAddressBook((ULONG)NULL,
NULL,AB_NO_DIALOG,&lpAddrBook);
//get Global Address List Container Interface pointer
BonHrFindExchangeGlobalAddressList(lpAddrBook, &lpGal);
//The IMAPIContainer::GetContentsTable method returns a pointer to the
container's contents table.
A contents table contains summary information about objects within
the container.
hRes = ((LPABCONT) lpGal)->GetContentsTable(0, &pTable);
//The contents table of an address book container lists information
about its messaging user and distribution list objects.
}
BOOL BonHrFindExchangeGlobalAddressList(LPADRBOOK lpAdrBook, LPMAPIPROP *lppAL)
{
// DESCRIPTION: Finds the global address list from the address book.
BOOL bRetVal = FALSE;
ULONG cbeid;
LPENTRYID lpeid = NULL;
ULONG ObjectType;
//HrFindExchangeGlobalAddressList ->retrieves the entry identifier of the global address list (GAL) container in the address book
HRESULT hRes = HrFindExchangeGlobalAddressList(lpAdrBook, &cbeid, &lpeid);
//Entry identifiers are pieces of binary data stored in an ENTRYID structure that are used to uniquely identify and open a MAPI object.
//OpenEntry->opens an address book entry and returns a pointer to an
interface that can be used to access the entry.
hRes = lpAdrBook->OpenEntry(cbeid, lpeid,NULL, MAPI_BEST_ACCESS,
&ObjectType,(LPUNKNOWN*) lppAL);
bRetVal = TRUE;
//Call the MAPIFreeBuffer function to free the property
tag array pointed to by lppPropTagArray
MAPIFreeBuffer(lpeid);
return bRetVal;
}
Krishan Gopal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|