Automatically create a task when sending a message

Last reviewed on May 22, 2013

This application startup macro watches for the user to send an email and asks if they want to create a task for the message. If they choose no, the message is sent. If they select yes then a task is created before the message is sent.

Create a task for the sent message

The code adds the message recipients to the task body, along with the message body. The start date is "today" (when the message is sent) and the due date is 2 days from now. The reminder is set for 2 days from now at 9 AM.

Create task from email

To automatically create tasks for messages you receive, see Create a Task from an Email using a Rule

Create task from sent message macro

To use this macro:

  1. Set macro security to low.
  2. Open the VBA Editor (Alt+F11)
  3. Expand Project1 to find ThisOutlookSession
  4. Copy the macro and paste at the top of ThisOutlookSession

Edit the start date, due date, and reminder time fields as needed.

To test the macro, click in the Application_Startup procedure and click the Run button then send a message.



Public WithEvents myOlApp As Outlook.Application

Private Sub Application_Startup()
    Initialize_handler
End Sub

Public Sub Initialize_handler()
    Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
    
Dim intRes As Integer
Dim strMsg As String
Dim objTask As TaskItem
Set objTask = Application.CreateItem(olTaskItem)
Dim strRecip As String

 strMsg = "Do you want to create a task for this message?"
 intRes = MsgBox(strMsg, vbYesNo + vbExclamation, "Create Task")
    
    
    If intRes = vbNo Then
      Cancel = False
    Else
      
    For Each Recipient In Item.Recipients
        strRecip = strRecip & vbCrLf & Recipient.Address
    Next Recipient

With objTask
    .Body = strRecip & vbCrLf & Item.Body
    .Subject = Item.Subject
    .StartDate = Item.ReceivedTime
    .ReminderSet = True
    .ReminderTime = DateSerial(Year(Now), Month(Now), Day(Now + 2)) + #9:00:00 AM#
    .Save
End With

    Cancel = False
      
    End If

Set objTask = Nothing
    
End Sub


Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

If the Post Coment button disappears, press your Tab key.