Outlook C++ com addin
COM
1
Posts
1
Posters
0
Views
1
Watching
-
Hi, I'm having a problem when iterating through the contacts in Outlook. I can create contacts ok and access all the properties of them, but when I try to iterate through them I get an exception. Can anyone see what I'm doing wrong :confused:
\_NameSpacePtr pNamespace; \_ItemsPtr pItems; \_FoldersPtr pFolders; MAPIFolderPtr pFolder; \_ContactItemPtr pContact; CComVariant vIndex; m\_spApp->GetNamespace(\_bstr\_t("MAPI"),&pNamespace); // select the default outlook contacts folder pNamespace->GetDefaultFolder(olFolderContacts,&pFolder); pFolder->get\_Items(&pItems); Outlook::OlObjectClass Class; CComBSTR EntryId; pItems->get\_Class(&Class); // iterate the list hr=pItems->GetFirst((IDispatch\*\*)&pContact); while ((hr==S\_OK) && (pContact!=NULL)) { pContact->get\_Class(&Class); if (Class==olContact) { pContact->get\_EntryID(&EntryId); // exception thrown on this line hr=pItems->GetNext((IDispatch\*\*)&pContact); } }
Any help you can offer would be greatly appreciated.;P