Tuesday, July 29, 2008

Expanding a (Personal) Distribution List using MAPI

To expand (get the individual email ids) the personal distribution list (MAPIPDL) follow these steps

  • Open the address book using the session pointer
  • open the PDL using IAddrBook::OpenEntry specifying its entry ID, which will give you an IDistList interface pointer
  • Call IDistList::GetContentsTable to get a pointer to the table of the this list
  • Optionally call SetColumns if you want only some properties
  • Call HrQueryAllRows to get a SRowSet containing the data you requested
Sample code is attached here
This sample is part of an application (posted without modification) which I wrote some time back. So, it does call some other members function but the meaning should be clear.

This sample may not be written in the best possible way, but it runs fine even if the address book doesn't support UNICODE (which was a requirement of my application)

No comments: