GetAssociatedTask Method Example

This example accepts a TaskRequestItem, sending the response without displaying the inspector.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myTasks = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myTaskReqItem = myTasks.Items.Find _
    ("[Subject] = ""Meeting w/ Jerry Wheeler""")
'The task is displayed.
myTaskReqItem.Display
Set myNewTaskItem = myTaskReqItem.GetAssociatedTask(True)
myNewTaskItem.Respond olTaskAccept, True, True

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myTasks = myNameSpace.GetDefaultFolder(6)
Set myTaskReqItem = myTasks.Items.Find _
    ("[Subject] = ""Meeting w/ Jerry Wheeler""")
'The task is displayed.
myTaskReqItem.Display
Set myNewTaskItem = myTaskReqItem.GetAssociatedTask(True)
myNewTaskItem.Respond 2, True, True