Display the task request items sent to a recipient

This example shows how to display all of the task request items that are in a recipient's Inbox.

Example

Note

The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007.

A TaskRequestItem object represents a request to assign a task to another user. The TaskRequestItem is created when the item is received in the recipient's Inbox. In the following code example, ShowTaskRequests filters through a recipient’s Inbox, creates a Table object, and inserts a row for each item for which the value of the MessageClass property equals IPM.TaskRequest. The subject of each task in the recipient’s Inbox folder is then written to the trace listeners of the Listeners collection.

If you use Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 15.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void ShowTaskRequests()
{
    string filter = "[MessageClass] = 'IPM.TaskRequest'";
    Outlook.Table table =
        Application.Session.GetDefaultFolder
        (Outlook.OlDefaultFolders.olFolderInbox).GetTable
        (filter, Outlook.OlTableContents.olUserItems);
    while (!table.EndOfTable)
    {
        Outlook.Row nextRow = table.GetNextRow();
        Debug.WriteLine(nextRow["Subject"]);
    }
}

See also