These messages are sent to the window handle (HWND) passed to the IPOutlookApp::Logon method. They are similar to the DB_CEOID_ messages from CEDB. The messages are sent only for databases (e.g., Appointments, Contacts, and Tasks) that you have subscribed to. Notifications are sent for both changes made by Outlook Mobile (the caller) via the _LOCAL messages, and for changes made by other processes via the _REMOTE messages.
You must subscribe for notifications by setting the PIMPR_FOLDERNOTIFICATIONS property on the folder you want, with the flags that you want. Possible flag values are PIMFOLDERNOTIFICATION_LOCAL and PIMFOLDERNOTIFICATION_REMOTE. The flags are independent, and you can set the value to 0 to stop notifications. For multiple folders of the same type, the last setting to this property from any of those folders, will be used for all such folders.
The following table lists the flags for receiving notifications.
Notification Value Description
PIMFOLDERNOTIFICATION_LOCAL
0x01
Notification for changes from this process.
PIMFOLDERNOTIFICATION_REMOTE
0x02
Notification for changes from other processes.
PIMFOLDERNOTIFICATION_ALL
0x03
Notification for changes from all processes. (PIMFOLDERNOTIFICATION_REMOTE | PIMFOLDERNOTIFICATION_LOCAL)
The following table lists the notification window messages for changes in local and remote processes.
Notification Value Description
PIM_ITEM_CREATED_LOCAL
WM_APP + 0x100
PIM item created locally.
Note:
wParam = Item OID, lParam = The folder containing the item.
Code Example 1
The following code example demonstrates how to subscribe to the different types of notifications.
Note:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
Copy Code
void NotificationsExample()
{
HRESULT hr = E_FAIL;
IPOutlookApp2 *pPoom = NULL;
// 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 a POOM session. Pass-in a valid handle to the POOM session parent window so the notifications can be processed from it's wndproc. Outlook Mobile uses this handle for each PIM item's Display call, as well as for the infrared transfer dialog.
hr = pPoom->Logon((long)hWnd);
// CASE 1: Subscribe to local and remote appointment notifications.
hr = SubscribeToNotifications(pPoom, olFolderCalendar, PIMFOLDERNOTIFICATION_ALL);
// CASE 2: Subscribe to remote contact notifications. I.e., changes made in another process.
hr = SubscribeToNotifications(pPoom, olFolderContacts, PIMFOLDERNOTIFICATION_REMOTE);
// CASE 3: Substribe for local task notifications. I.e., changes made in this process.
hr = SubscribeToNotifications(pPoom, olFolderTasks, PIMFOLDERNOTIFICATION_LOCAL);
// Insert your code for creating a dialog window, here.
return;
}
Code Example 2
The following code example demonstrates how to subscribe to notifications based on folder type.
Note:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
Copy Code
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);