Hello there,
I am trying to access the contacts in smartphones and Pocket PCs using POOM in Visual Studio 5.0.
I managed to use this code from the internet (with small changes):
//*******************************************************************
#include
"pimstore.h"typedef
CComQIPtr<IPOutlookApp,&__uuidof(IPOutlookApp)>IPOutlookAppPtr;
typedef
CComQIPtr<IFolder,&__uuidof(IFolder)> IFolderPtr;typedef
CComQIPtr<IPOutlookItemCollection,&
__uuidof(IPOutlookItemCollection)>IPOutlookItemCollectionPtr;
typedef
CComQIPtr<ITask,&__uuidof(ITask)> ITaskPtr;IPOutlookAppPtr m_pPOOMApp;
bool m_bLoggedIn;HRESULT hr = 0;
CLSID clsid;
IFolderPtr pFolder;
LPOLESTR pProgID = L
"PocketOutlook.Application";hr = CoInitializeEx(NULL, 0);
if (hr == S_FALSE){return (FALSE);}hr = CLSIDFromProgID(pProgID,&clsid);
hr = m_pPOOMApp.CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER);
if ( SUCCEEDED(hr) ){
// perform login if(SUCCEEDED(m_pPOOMApp->Logon(NULL)))
{
m_bLoggedIn = TRUE;
}
}
if (m_bLoggedIn && SUCCEEDED(m_pPOOMApp->GetDefaultFolder(olFolderTasks, &pFolder))) {if (SUCCEEDED(pFolder->get_Items(&pItemCol)))IPOutlookItemCollectionPtr pItemCol;
CComBSTR bstrText;
{
int cItems = 0;
hr = pItemCol->get_Count(&cItems);
for (int i = 1; i <= cItems; i++){
if ( SUCCEEDED(pItemCol->Item(i,(IDispatch**)&pTask)) )ITaskPtr pTask;
{
}hr = pTask->get_Subject(&bstrText);
}
}
}
CoUninitialize();
//*******************************************************************
Unfortunately, although I have contact items on my device, when I run :
hr = pItemCol->get_Count(&cItems);
cItems remains 0 even if there are 20 contacts in my list.
Would you have any idea what is wrong mith my code
Thanks a lot for your help.
regards,
NONO_COOL.

Problem using POOM
Bertrand Caillet
Thanks a lot Rupali for your reply.
I felt a bit stupid reading your message :) since that mistakes is obvious.
However, I replaced "olFolderTasks" with "olFolderContacts" on the line you mentioned.
After running :
hr = pItemCol->get_Count(&cItems);
same problem, cItems is still 0! even with many contacts... :(
Any idea
Thanks a lot again!
Lauriew
Re-deploying doesn't change anything. Thanks for the suggestion though. I believe the problem comes from the need for the company to be registered. The contacts can't get accessed for security reasons. This is true with phones using Windows Mobile 2005. I will carry on working on the emulator, since it works there and leave my company deal with this later.
Thanks guys for your help and suggestions.
Regards,
NONO_COOL
A..K
if (m_bLoggedIn && SUCCEEDED(m_pPOOMApp->GetDefaultFolder(olFolderTasks, &pFolder)))
The code line above is trying to get the default tasks folder which could explain why the count is zero. You need to get the default contacts folder using olFolderContacts instead of olFolderTasks.
Thanks
Rupali
calmal20
AndyL
I found out that with the last change it works in the emulator but not on the phone.
Any suggestions is the most welcome... ;)
Cheers!