Mar 09
11
Using Search Folders in Outlook 2007 for GTD
One of my favorite features of Outlook 2007 is Search Folders. A Search Folder is a dynamic folder, automatically populated based on a query. For example, a Search Folder can be used to show all email over 1Mb in size.
Being a GTD (Getting Things Done) addict, I wanted to see if I could use Search Folders to create separate folders for each of my project categories. For example, if I have an Outlook category called TechEd 2009, wouldn’t it be nice to have a couple of search folders – one to show all of the active tasks associated with that category, the other to show all of the mail filed under that category.
Out of the box however, this is a little difficult to setup – while you can easily create a Search Folder that displays mail relating to a category, in Outlook 2007 you can’t actually create a Search Folder that filters on tasks. After a little digging, I found out that Search Folders do support the capability of filtering other types of objects, but only querying of mail items are exposed in the Outlook UI.
To overcome this limitation however, we can use a simple macro:
Sub CreateNewSearchFolder()
Set MyOutlookApplication = Outlook.Application
SearchSubFolders = True
Set MapiNamespace = Application.GetNamespace("MAPI")
Set TasksFolder = MapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Parent
strS = "’" & TasksFolder.FolderPath & "’"
Dim folderName As String
folderName = InputBox("What category would you like to create a search folder for?:", "Category", "")
Dim objSch As Search
Dim categoryFilter As String
categoryFilter = "(""urn:schemas-microsoft-com:office:office#Keywords"" LIKE ‘%" & folderName & "%’)"
Dim taskFilter As String
taskFilter = "(""http://schemas.microsoft.com/mapi/proptag/0×0e05001f""= ‘Tasks’ AND ""http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81010003"" <> 2) OR (NOT(""http://schemas.microsoft.com/mapi/proptag/0×10900003"" IS NULL) AND ""http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81010003"" <> 2)"
Dim strTag As String
strTag = "RecurSearch"
‘ Create the tasks folder
Set objSch = Application.AdvancedSearch(Scope:=strS, Filter:=categoryFilter & " AND (" + taskFilter + ")", _
SearchSubFolders:=True, Tag:=strTag)
objSch.Save (folderName)
‘ Create the mail folder
Set objSch = Application.AdvancedSearch(Scope:=strS, Filter:=categoryFilter, _
SearchSubFolders:=True, Tag:=strTag)
objSch.Save (folderName & " (Mail)")
End Sub
The above macro will prompt you for a category name and auto-magically create two search folders – one that will display the active tasks assigned to that category, and one that will display all items (both mail and tasks) assigned to that category.
Your mileage with this may vary (and I’m sure you’ll believe me when I say the above is not officially supported
) but I’ve found this very useful to look at active tasks and filed mail for a specific GTD category without leaving the comfort my email folder list.