C
Code Blue
Hi,
I can't believe that no (public) code exists that WORKS and clearly shows
how to get POOM notification events to your app.
I tried the MSDN example for getting PIM_ITEM_REMOTE_CREATED but my app
never gets notified.
the Logon(hWnd) function returns S_OK, and so does the subscription
function. Is there anything extra that needs to be done???
Here's the code provided by MSDN which I'm using:
(WndProc Message handling not shown, I'm just showing a messagebox when the
message is received, which never happens)
Thanks,
Alex
void OutlookNotifications()
{
HRESULT hr = E_FAIL;
// Initialize COM for using the Pocket Outlook Object Model (POOM).
CoInitializeEx(NULL, 0);
// Get a reference to the POOM (Outlook Mobile) application object.
hr = CoCreateInstance(CLSID_Application,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPOutlookApp2,
(LPVOID*)&pPoom);
// Logon to the POOM session.
hr = pPoom->Logon((long)hWnd);
// Subscribe to local and remote appointment notifications.
hr = SubscribeToNotifications(pPoom, olFolderCalendar,
PIMFOLDERNOTIFICATION_ALL);
// Insert your code for creating a dialog window, here.
return;
}
// Function to subscribe to notifications based on folder type.
HRESULT SubscribeToNotifications(IPOutlookApp2 *pPoom, OlDefaultFolders
olFolder, uint uiNotificationsType)
{
HRESULT hr = 0;
IFolder *pFolder = NULL;
IItem *pItem = NULL;
CEPROPVAL propval = {0};
// Get the folder for the item type.
hr = pPoom->GetDefaultFolder(olFolder, &pFolder);
// Get the IItem interface for the IFolder.
hr = pFolder->QueryInterface(IID_IItem, (LPVOID*)&pItem);
// Set the folder's properties.
propval.propid = PIMPR_FOLDERNOTIFICATIONS;
propval.val.ulVal = uiNotificationsType;
hr = pItem->SetProps(0, 1, &propval);
pItem->Release();
pFolder->Release();
return hr;
}
I can't believe that no (public) code exists that WORKS and clearly shows
how to get POOM notification events to your app.
I tried the MSDN example for getting PIM_ITEM_REMOTE_CREATED but my app
never gets notified.
the Logon(hWnd) function returns S_OK, and so does the subscription
function. Is there anything extra that needs to be done???
Here's the code provided by MSDN which I'm using:
(WndProc Message handling not shown, I'm just showing a messagebox when the
message is received, which never happens)
Thanks,
Alex
void OutlookNotifications()
{
HRESULT hr = E_FAIL;
// Initialize COM for using the Pocket Outlook Object Model (POOM).
CoInitializeEx(NULL, 0);
// Get a reference to the POOM (Outlook Mobile) application object.
hr = CoCreateInstance(CLSID_Application,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPOutlookApp2,
(LPVOID*)&pPoom);
// Logon to the POOM session.
hr = pPoom->Logon((long)hWnd);
// Subscribe to local and remote appointment notifications.
hr = SubscribeToNotifications(pPoom, olFolderCalendar,
PIMFOLDERNOTIFICATION_ALL);
// Insert your code for creating a dialog window, here.
return;
}
// Function to subscribe to notifications based on folder type.
HRESULT SubscribeToNotifications(IPOutlookApp2 *pPoom, OlDefaultFolders
olFolder, uint uiNotificationsType)
{
HRESULT hr = 0;
IFolder *pFolder = NULL;
IItem *pItem = NULL;
CEPROPVAL propval = {0};
// Get the folder for the item type.
hr = pPoom->GetDefaultFolder(olFolder, &pFolder);
// Get the IItem interface for the IFolder.
hr = pFolder->QueryInterface(IID_IItem, (LPVOID*)&pItem);
// Set the folder's properties.
propval.propid = PIMPR_FOLDERNOTIFICATIONS;
propval.val.ulVal = uiNotificationsType;
hr = pItem->SetProps(0, 1, &propval);
pItem->Release();
pFolder->Release();
return hr;
}