Iterating contacts (Outlook Com C++)

R

Richard Bang

Could anyone tell me why this code fails as I cannot figure it out and this
is my first com plug in

_NameSpacePtr pNamespace;
_ItemsPtr pItems;
_FoldersPtr pFolders;
MAPIFolderPtr pFolder;
_ContactItemPtr pContact;
m_spApp->GetNamespace(_bstr_t("MAPI"),&pNamespace);
// select the default outlook contacts folder
pNamespace->GetDefaultFolder(olFolderContacts,&pFolder);
pFolder->get_Items(&pItems);
hr=pItems->GetFirst((IDispatch**)&pContact);
while (hr==S_OK)
{
CComBSTR Value;
pContact->get_EntryID(&Value); // exception thrown on this line
pContact->Release();
hr=pItems->GetNext((IDispatch**)&pContact);
}

The failure when trying to get EntryId is a real pain.

Any help would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top