Renaming Tasks in Microsoft Office 2007 (GTD)
While using Outlook 2007 as my GTD tool, one of the things I’ve been missing is having the ability to rename tasks on the fly. Here’s a pretty common situation:
· A new message arrives with the subject of “RE: Purchase Order”. It’s from Jack, and after reading the Email I realize that I need to call Bob to confirm the quantity.
· I flag it as a task in Outlook, assign some categories (let’s say @Office and ProjectX), and move it to my tasks folder.
· As you may know, this creates a new task with the subject of “RE: Purchase Order”. What I really want however is to change the name of the task to something more descriptive – for example “Speak to Bob about quantity required for the order”.
You can do this renaming in the to-do list, but this requires the step of going into the to-do list, finding the aforementioned task and then changing the name in the list.
After figuring out that I needed something more automated, I wrote the following macro:
Function FileFolderEntryId() As String
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myInbox As Outlook.folder
Dim rootFolder As Outlook.folder
Dim subFolders As Outlook.Folders
Dim subFolder As Outlook.folder
Dim fileFolder As Outlook.folder
Dim fileEntryID As String
Dim fileFolderName As String
'Set the folder name – must be at the same level as the inbox
fileFolderName = "File"
' Move the the file folder
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myInbox = myNamespace.GetDefaultFolder(olFolderInbox)
Set rootFolder = myInbox.Parent
Set subFolders = rootFolder.Folders
Set subFolder = subFolders.GetFirst
Do While Not subFolder Is Nothing
If subFolder.Name = fileFolderName Then
fileEntryID = subFolder.EntryID
Exit Do
End If
Set subFolder = subFolders.GetNext
Loop
' return the entry ID for the file folder
FileFolderEntryId = fileEntryID
End Function
Sub NewTask()
Dim item As MailItem
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim fileFolder As Outlook.folder
Dim newName As String
' Pick the category
Set item = Outlook.Application.ActiveExplorer.Selection.item(1)
' Mark as unread
item.UnRead = False
item.Save
item.ShowCategoriesDialog
'validate to see whether two categories exist, including an action
If (item.categories <> "") Then
If (InStr(item.categories, "@") > 0) Then
If (InStr(item.categories, ",") > 0) Then
le="margin: 0in 0in 0pt"> ' Set the follow up flag
item.MarkAsTask (olMarkNoDate)
' Move the item to the file folder
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set fileFolder = myNamespace.GetFolderFromID(FileFolderEntryId())
' Ask for a different name if required
newName = InputBox("Please enter a subject for the task:", "Task Subject", item.TaskSubject)
item.TaskSubject = newName
item.Save
item.Move fileFolder
End If
End If
End If
End Sub
The above does everything for me – assigns the categories, and prompts me for a task subject before moving it to my file folder (highlighted). What’s really nice about this is that the subject of the underlying Email remains the same (it’s only the task’s subject that changes). This means that after I’ve spoken to Bob about the quantity, the reply to the original Email from Jack will still have the original subject of “RE: Purchase Order”. Pretty Cool.
*** Update: Fixed post with the FileFolderEntryId() function ***
Trying to get this working in Outlook 2007. Tracing through I see the call to item.Save happening after the subject is renamed, but the email never appears in the task list. It does however move to the File folder with the correct categories. Any ideas?
I am a complete macro neophyte, so please bare with me. Is there any way to create a macro (ideally accessible through a key board shortcut) which will create a new task and attach the highlighted email (instead of transcribing the email to the note section, which is what dragging an email to the taskbar does).
When processing email I usually create a new task, fill in the subject and categories and drag and drop the email as an attachment so that the email itself is kept in the task. This allows me to delete the email from my inbox, but respond to the original email if I have to while actually performing the task.
I apologize if this script does that, but I can’t get it to work to try it out. I get a “Compile error: User-defined type not defined” when I run it.
Just rename fileFolderName = “Tasks”, sorted.
To Answer Felipe, this macro should be run on a Mail item and not a task.
Thanks for posting this. Really appreciate being able to look over your shoulder on your implementation of GTD in Outlook 2007. Could I ask you if there is a way to do what this macro does, but (after assigning a category) both create a task with a copy of the e-mail message attached and file the original message in an e-mail folder? I’ve been trying to figure it out on my own, but no luck so far.
Thanks,
Josh
I have been trying to edit this macro to do 2 things differently, but failed miserably and any help would be much appreciated:
-Instead of moving the email to a set folder, it should show me the folder list and let me choose where I want it to go.
-Instead of copying the email text into the task it should attach a copy of the email itself to the task.
This is really driving me crazy and I would appreciate any help you guys can give me.
I know this post is rather old but I’m hoping you can provide an answer. Basically when I run this on a mail item all it does is change the category. It doesnt get marked as unread, flagged as a task or ask to be renamed. Im not getting any errors in the macro, so Im guessing it has something to with the conditionals. Thank you.