PDA

View Full Version : Create Task in Public Folder From Current Email



stillmc
07-07-2010, 12:30 PM
I am trying to write a macro which will create a task in a public folder from the current email. I have the following code to create the task, but I can't figure out how to specify a specific public folder for the task. Ideas?

Public Sub AddTaskItem()
Const strMailItem As String = "MailItem"
Dim objExplorer As Outlook.Explorer
Dim objMailItem As Outlook.MailItem
Dim objTaskItem As Outlook.TaskItem

Set objExplorer = Application.ActiveExplorer

If TypeName(objExplorer.Selection(1)) = strMailItem Then
Set objMailItem = objExplorer.Selection(1)
'create task with date of today and due date of 5:00pm tomorrow
Set objTaskItem = Application.CreateItem(olTaskItem)
With objTaskItem
.Subject = objMailItem.Subject
.Body = objMailItem.Body
.StartDate = Date
.DueDate = Date + 1
.ReminderTime = .DueDate & " 17:00"
.Save
.Display
End With
End If
End Sub