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
olItem.Delete
Next
olTask.Display
'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
olTask.Save
End Sub
Comments
Anonymous
January 01, 2003
PingBack from http://www.johnplummer.com/tools/outlook-item-to-task-macro.htmlAnonymous
January 31, 2004
This works a treat. I saw the original but I like what you've done with it.
This is now on my toolbar :o)Anonymous
January 31, 2004
Although, I must admit I removed "olItem.Delete" as I prefer to keep the original mails ;o)Anonymous
February 04, 2004
The comment has been removedAnonymous
June 29, 2004
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 peterAnonymous
June 30, 2004
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 attachmentsAnonymous
June 30, 2004
Peter: I haven't tried it out, but I suspect something like this would work:
Replace this:
olTask.Attachments.Add olItem
With:
olTask.body = oltask.body & vbcrlf & olitem.bodyAnonymous
July 01, 2004
The comment has been removedAnonymous
July 02, 2004
I don't have any expertise in what determines the insertion point of the attachment, sorry.Anonymous
July 20, 2004
Hi,
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.
Thanks
Narayanan Sankararanarayanan