How to: Find a PIM Item Within a Collection
Locating a particular PIM item within the Pocket Outlook database involves calling the IPOutlookItemCollection::Find method on the collection.
The Pocket Outlook database consists of three separate PIM item lists contained in the three default folders: the Appointments folder, the Tasks folder, and the Contacts folder.
To find a task by subject
Create an instance of the Pocket Outlook application object and then use it to establish a POOM session. For more information, see How to: Establish a POOM Session.
Declare a reference to a generic PIM item collection, as follows:
IPOutlookItemCollection *pItems;
Declare a reference to a generic PIM item folder:
IFolder *pFolder;
Declare a reference to a Task item:
ITask *pFoundTask;
Use the generic PIM item folder to get the Tasks folder:
polApp->GetDefaultFolder(olFolderTasks, &pFolder);
Use the Tasks folder to get the collection of Task items:
pFolder->get_Items(&pItems)
Search the collection of Task items for an item that matches your search criteria:
pItems->Find(_T("[Subject] = \"meeting\""), reinterpret_cast<IDispatch **>(&pFoundTask));
Example
The following code demonstrates how to retrieve a Task item from the Tasks folder, based on the information in its Subject property.
BSTR restriction = "[Subject] = \"meeting\"";
void FindTask(IPOutlookApp *polApp, ITask *pFoundTask, BSTR restriction)
{
IPOutlookItemCollection *pItems;
IFolder *pFolder;
polApp->GetDefaultFolder(olFolderTasks, &pFolder)
pFolder->get_Items(&pItems);
pItems->Find(_T(restriction),
reinterpret_cast<IDispatch **>(&pFoundTask));
// Free memory.
pItems->Release();
pFolder->Release();
pTask->Release();
}
See Also
Last updated on Friday, April 22, 2005
© 2005 Microsoft Corporation. All rights reserved.
Send feedback on this topic to the authors.