Daniele Salvatore Albano
Daniele Salvatore Albano

Reputation: 1263

extract contacts and distribution lists (groups) from wab (mapi)

I'm looking a way to extract all contacts and distribution list (with related contacts) from a WAB (Windows Address Book).

I need to do this because I need to import address books, with distribution lists/groups, in roundcube.

After some research, I've founded a C++ project on Code Project ( http://www.codeproject.com/Articles/3407/Accessing-the-Windows-Address-Book ), but this support only contacts.

Looking around on MSDN I've founded that the OpenEntry method of iAddrBook should support in the third parameter the interface to open, iDistList in my case, but I can't find anywhere the interface id.

I searched some documentation abount WAB file structure, but nothing.

Any suggestions?

Upvotes: 0

Views: 593

Answers (1)

marcinj
marcinj

Reputation: 49976

Here is a path I used to acomplish this:

  1. I use WABOpen method from wab32 dll to get LPADRBOOK lpAddr;
  2. I set PAB folder lpAddr: call lpAddr->GetPAB(), OpenEntry to get container, then GetContentsTable on container to get LPMAPITABLE lpTable.
  3. To get table element count use GetRowCount on lpTable
  4. To verify if given table row is a distribution list, use QueryRows, this should return MAPI_DISTLIST or MAPI_MAILUSER.
  5. If this is a MAPI_DISTLIST row then use its PR_ENTRYID to call lpAdrBook->OpenEntry(), this should return IABContainer container on which you call GetContentsTable to get table with contents of this distribution list.

the last OpenEntry looks as follows, I do not set third parameter anywhere:

  // Now emails will be loaded.
  ULONG ulObjType;
  IUnknown* lpUnk;
  hr = lpAdrBook->OpenEntry(DistEntryId.size, (LPENTRYID)DistEntryId.ab, NULL, 0,   &ulObjType, &lpUnk );
  if (FAILED(hr)) {
   assert(false); return hr;
  }

Upvotes: 1

Related Questions