Create a task from an email

John Durant recently blogged about his macro to create a task from an e-mail. I thought that was a great idea, so I modified it a bit to suit my purposes. I frequently take an item from my inbox and Edit | Move to Folder and move it to the tasks folder, which creates a task item. I then tab around to set the reminder (which is frustrating if I want it to remind me later today, because if I put ‘today’ in the due date, it doesn’t set the reminder, thus resulting in more keystrokes).

This macro does the following:

1. Takes the items that are selected (it can handle multiple selections of any item type)
2. Creates a task
3. Attaches those items
4. Deletes the items from the source folder
5. Saves the task (so worst case, you can go get the items from the task if you didn’t want them to be removed)
6. Sets the reminder on the task to 3 hours from now (you can easily tab into the due date field and set it to tomorrow, tuesday, etc, which will in turn change the reminder)

So, here’s what I did:

1. Copy the code into ThisOutlookSession per the instructions in this entry
2. Add a toolbar button for this macro per the instructions in this entry (Note: K as an accelerator isn’t used by default in the standard toolbars, so Create Tas&k is a good name – you can also change the icon to something else in that menu as well)

And finally, the code:

Public Sub CreateTaskFromItem()

  Dim olTask As Outlook.TaskItem
  ‘Using object rather than MailItem, so that it
  ‘can handle posts, meeting requests, etc as well

  Dim olItem As Object
  Dim olExp As Outlook.Explorer
  Dim fldCurrent As Outlook.MAPIFolder
  Dim olApp As Outlook.Application
  Set olApp = Outlook.CreateObject(“Outlook.Application”)
  Set olTask = olApp.CreateItem(olTaskItem)
  Set olExp = olApp.ActiveExplorer
  Set fldCurrent = olExp.CurrentFolder
  Dim cntSelection As Integer
  cntSelection = olExp.Selection.Count
  For i = 1 To cntSelection
    Set olItem = olExp.Selection.Item(i)
    olTask.Attachments.Add olItem
    olTask.Subject = “Follow up on ” & olItem.Subject

  ‘Set the due date for today
  olTask.DueDate = Date
  ‘Set the reminder for 3 hours from now
  olTask.ReminderSet = True
  olTask.ReminderTime = DateAdd(“h”, 3, Now)
  ‘Saving the task item, so that in case I close it, I won’t lose
  ‘the items which were deleted after being attached to the task

End Sub

Comments (10)

  1. Colin Walker says:

    This works a treat. I saw the original but I like what you’ve done with it.

    This is now on my toolbar :o)

  2. Colin Walker says:

    Although, I must admit I removed "olItem.Delete" as I prefer to keep the original mails ;o)

  3. Steve Downs says:

    I have to ask, what is wrong with drag and drop?

    Drag e-mail to tasks, task opens click the reminder check box, click (and hold) on the down arrow for the time and keep holding the button down below the bottom of the dropdown time list list untill it scrolls to the time you want, slide mouse to highlight let go and click save and close. Push your delete key to delete the e-mail. That takes less that 3 seconds.

    I supose if you really want the cool macro button that’s ok but drag and drop is easy too.

    By the way the junk mail filter on Outlook 2003 Rocks. The team that came up with it ought to get a big promotion. I spent about 4-5 days using Outlook and marking what I didn’t want. I seldom receive an junk e-mail now. Good Job

    Oh and while I’m at it hiding the graphics in the messages untill you want to show them is an awesome feature too.

  4. Peter Duckett says:

    I like what you have done with the code very smart!! but will it add file attacements as well as the email to the task as well as i have been havin problems doing this!! thanks peter

  5. Peter Duckett says:

    What i meant to say is how can i just copy the email inot a task in the same format without putting it into an attachments

  6. KC Lemson says:

    Peter: I haven’t tried it out, but I suspect something like this would work:

    Replace this:

    olTask.Attachments.Add olItem


    olTask.body = oltask.body & vbcrlf & olitem.body

  7. Peter Duckett says:

    Thank you for you last comment that worked fine i was able to copy the emails body into an task easy enough using that but i would i would like to copy the attachments over too in the same position that it was placed.

    I had tryied this code which copys the attacment and then adds it to the task supposed to be in the same position but it seems it comes out completly random placement left or right to where its supposed to be

    OlOrig.Attachments.Item(i).SaveAsFile "C:" & OlOrig.Attachments.Item(i).DisplayName

    objattachments.Add "C:" & OlOrig.Attachments.Item(i).DisplayName, , OlOrig.Attachments.Item(i).position

    Kill ("C:" & OlOrig.Attachments.Item(i).DisplayName)

    If you could help just to copy over these attachments in the correct place i would be very happy thank you

  8. KC Lemson says:

    I don’t have any expertise in what determines the insertion point of the attachment, sorry.

  9. Narayanan Sankaranarayanan says:


    I am Narayanan Sankararanarayanan.

    We have a web-based application that has reminders for users.

    These reminders popup as long as they are in the web-based application. We have Outlook as our corporate email client.

    We want these reminders to be part of outlook/exchange.

    Here is my question: How will you create a task for somebody? It should look like that person by him/herself has created the task.


    Narayanan Sankararanarayanan