A
Ashley
I have created a custom form in Outlook and I would like to create a macro that when the email is sent, it also creates an outlook task from the email.
I have create the code below that works if I send the email to myself and then open it and run the macro. I think my problem is that I using MailItem and at the point I am trying to run the marco the email hasn't been sent. I may need to use CurrentItem but I can't seem to get the code right. Help...
Sub TaskFromEmail()
Dim item As MailItem
Set item = Outlook.Application.ActiveExplorer.Selection.item(1)
Dim olApp As Outlook.Application
Dim olTsk As TaskItem
Dim userField As Outlook.UserProperty
Set olApp = New Outlook.Application
Set olTsk = olApp.CreateItem(olTaskItem)
With olTsk
.Subject = item.Subject
.Status = olTaskNotStarted
.Body = item.Body
'This is a custom field to update DueDate in the Task
Set ups = item.UserProperties
Set prp = ups.Find("DateDue")
.DueDate = ups("DateDue").Value
.Save
End With
Set olTsk = Nothing
Set olApp = Nothing
End Sub
Submitted using http://www.outlookforums.com
I have create the code below that works if I send the email to myself and then open it and run the macro. I think my problem is that I using MailItem and at the point I am trying to run the marco the email hasn't been sent. I may need to use CurrentItem but I can't seem to get the code right. Help...
Sub TaskFromEmail()
Dim item As MailItem
Set item = Outlook.Application.ActiveExplorer.Selection.item(1)
Dim olApp As Outlook.Application
Dim olTsk As TaskItem
Dim userField As Outlook.UserProperty
Set olApp = New Outlook.Application
Set olTsk = olApp.CreateItem(olTaskItem)
With olTsk
.Subject = item.Subject
.Status = olTaskNotStarted
.Body = item.Body
'This is a custom field to update DueDate in the Task
Set ups = item.UserProperties
Set prp = ups.Find("DateDue")
.DueDate = ups("DateDue").Value
.Save
End With
Set olTsk = Nothing
Set olApp = Nothing
End Sub
Submitted using http://www.outlookforums.com