Create and assign an outlook task using VBA?

T

Todd

I have code that creates an Outlook task for me. I want to be able to
automatically assign a task to a certain e-mail address recipient. Is this
possible? It seems that the right properties are available, but I can't
seem to get it to work. Here is my code...

Private Sub Create_It_Click()
'Create the Task in Outlook
On Error GoTo AddAppt_Err
Dim outobj As Outlook.Application
Dim outtask As Outlook.TaskItem
'Dim objApptOccur As TaskItem

Set outobj = CreateObject("outlook.application")
Set outtask = outobj.CreateItem(olTaskItem)
With outtask
.subject = Me!subject
.Body = Me!txtBody
Select Case cmbImportance
Case "High"
.Importance = olImportanceHigh
Case "Normal"
.Importance = olImportanceNormal
Case "Low"
.Importance = olImportanceNormal
End Select
.Assign 'This seems to set the task to be assigned
outtask.Display
End With
' Release the Outlook object variable.
Set outobj = Nothing
DoCmd.Close
Exit Sub

The code creates a task, inputs the subject, body, and importance, and sets
the task to be assigned. I just can't seem to automatically put in the
e-mail address in the "To:" field. I thought that it might be '.recipients
= "e-mail address"' but that didn't work. Any ideas? Thanks!!!

Todd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top