Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

Listing all of the PIM items contained in a particular folder involves determining the number of items in the folder and then looping through the collection to iteratively retrieve a particular PIM item from the database. For more information retrieving PIM items, see Retrieving a PIM Item from the Outlook Mobile Database.

The Outlook Mobile 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 list all the Task items in the Tasks folder

  1. Create an instance of the Outlook Mobile application object and then use it to establish a POOM session. For more information, see Establishing a POOM Session.

  2. Declare a reference to a generic PIM item collection, as follows:

    Copy Code
    IPOutlookItemCollection * pItems;
    
  3. Declare a reference to a generic PIM item folder:

    Copy Code
    IFolder * pFolder;
    
  4. Declare a reference to a Task item:

    Copy Code
    ITask * pTask;
    
  5. Use the generic PIM item folder to get the Tasks folder:

    Copy Code
    polApp->GetDefaultFolder(olFolderTasks, &pFolder);
    
  6. Use the Tasks folder to get the collection of Task items:

    Copy Code
    pFolder->get_Items(&pItems)
    
  7. Loop through the collection of Task items, and get each item, as follows:

    Copy Code
    for(int counter = 0; counter < total; counter++) {
    	pItems->Item(counter, &pTask);
    
    	\\ Output details for each Task item.
    
    	pTask->Release();
    }
    

Example

The following code example demonstrates how to list all of the Task items in the Tasks folder.

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 ListTasks(IPOutlookApp * polApp)
{
	IPOutlookItemCollection * pItems;
	IFolder				 * pFolder;
	ITask				 * pTask;
	int					 total;

	polApp->GetDefaultFolder(olFolderTasks, &pFolder)

	pFolder->get_Items(&pItems);
	pItems->get_Count(&total);

	for(int counter = 0; counter < (total + 1); counter++)
	{
		pItems->Item(counter, 
&pTask);

		\\ Output details for each Task item.

		pTask->Release();
   }
}

To make the 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.

Compiling the Code

  • Include Header File: PimStore.h

  • Linker Dependency: PimStore.lib

See Also