Macro Defined Custom Outlook Search Folders
I use the built-in Outlook "Sent Directly To Me" search folder as my hot items in Outlook. If my name is on the To or CC line for an email, it's probably something I want to look at fairly quickly.
The problem is that I'm starting to get a lot of noise. We have a lot of social distribution lists (Xbox gamers, Skiing, Motorcycle Riders, etc.) Some of these lists get a lot of traffic. If I send a message to a list, there could be 30-40 replies that show up in my "Sent Directly To Me" folder. It's very disruptive to my work. I only check those social lists once or twice a day. I don't want to be bothered with them while I am working.
I set about trying to create a custom search folder that excluded anything sent to specific mailing lists. I was quickly stumped though. There doesn't seem to be any way to specify boolean AND, OR, NOT searches. In the advanced tab of the custom search definition dialog, there is a "More Advanced..." button, but it's never enabled for me. I wonder if that is hiding the functionality I want?
That's when I stumbled across this post which talks about how to write a macro to specify your own search folders. The syntax for writing the filter is ridiculously complicated, but these links should help.
Here is an example search that looks through my entire mail box for anything with my name on the To line:
Sub CreateSearch()
Dim oSearch As Outlook.Search
Dim strScope As String
strScope = "'\\Mailbox - Ben Martens'"
Dim strFilter As String
strFilter = "urn:schemas:httpmail:displayto ci_phrasematch 'Ben Martens'"
Set oSearch = Application.AdvancedSearch(strScope, strFilter, True)
Dim newFolder As Folder
Set newFolder = oSearch.Save("Ben's Custom Search")
End Sub
That last line saves the search into the "Search Folders" tree and it behaves like any other search folder. This is a very basic search, but you can probably see how much deeper you could dive with that filter. If I was to continue, I would create an AND NOT phrase that filtered out specific mailing lists.
At this point, I turned around to show my office mate. While I was explaining it to him, I realized that the Outlook custom search UI lets you restrict which folders a search takes place on. That means I can simply right click on the "Sent Directly To Me" search folder and choose which folder it operates on.
But really, what fun is that!?
Comments
- Anonymous
December 13, 2007
PingBack from http://blog.robinzhong.com/index.php/archives/2007/12/14/231.html