(Solved) – Outlook – VBA Send email when Task is Completed – New approach

(solved)-–-outlook-–-vba-send-email-when-task-is-completed-–-new-approach

I’m using the script below to auto convert emails to tasks:

Sub ConvertMailtoTask(Item As Outlook.MailItem)
    Dim objTask As Outlook.TaskItem
    Set objTask = Application.CreateItem(olTaskItem)
With objTask
    .Subject = Item.Subject
    .StartDate = Item.ReceivedTime
    .Body = Item.Body
    .Companies = Item.SenderEmailAddress
    .Save
End With
    Set objTask = Nothing
End Sub

I’d also like to auto send an email to the recipient everytime a task is completed without having to assing the task. I’ve tried the approach below but nothing gets returned. Any ideas why?

Sub Item_PropertyChange(ByVal Name)
    Set oMsg = Application.CreateItem(olMailItem)
    If Item.Status = 2 Then
        With oMsg
            .To = "myemailaddress"
            .Subject = "Task Completed"
            .Body = Item.Subject
            .Send
        End With
    End If
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *