Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: 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.

Programming Applications for Office Outlook 2007

The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007, from Microsoft Press (ISBN 9780735622494, copyright Microsoft Press 2007, all rights reserved).

Buy this book

Sample chapters

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 Microsoft Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 14.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"]);
    }
}

Other Resources

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.