Assign Method

Assigns a task and returns a TaskItem object that represents it. This method allows a task to be assigned (delegated) to another user. You must create a task before you can assign it, and you must assign a task before you can send it. An assigned task is sent as a TaskRequestItem object.


*expression   * Required. An expression that returns a TaskItem object.


This Visual Basic for Applications (VBA) example uses CreateItem to create a simple task and delegate it as a task request to another user. To run this example, replace 'Dan Wilson' with a valid recipient name.

Sub AssignTask()
    Dim myOlApp As New Outlook.Application
    Dim myItem As Outlook.TaskItem
    Dim myDelegate As Outlook.Recipient
    Set MyItem = myOlApp.CreateItem(olTaskItem)
    Set myDelegate = MyItem.Recipients.Add("Dan Wilson")
    If myDelegate.Resolved Then
        myItem.Subject = "Prepare Agenda For Meeting"
        myItem.DueDate = Now + 30
    End If
End Sub

If you use Microsoft Visual Basic Scripting Edition (VBScript) in a Microsoft Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to assign a task item using VBScript.

Set myItem = Application.CreateItem(3)
Set myDelegate = myItem.Recipients.Add("Dan Wilson")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/03#

Applies to | TaskItem Object