How to: Respond to a Task Request Item

Office 2013 and later

This example shows how to get and respond to a task request item.

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

In the following code example, AcceptTaskRequest uses the GetAssociatedTask(Boolean) method of the TaskRequestItem object to get the TaskItem object. The example then calls the Respond(OlTaskResponse, Object, Object) method with the parameter set to olTaskAccept to accept the task request.

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 AcceptTaskRequest()
    string filter = "[MessageClass] = 'IPM.TaskRequest'";
    Outlook.Items items =
    if (items.Count > 0)
        Outlook.TaskRequestItem taskRequest =
        Outlook.TaskItem task =
        Outlook.TaskItem taskResponse = task.Respond(
            Outlook.OlTaskResponse.olTaskAccept, true, false);

Other resources