Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How can I search for specific Outlook categories using raw query?

I'm using Outlook 2011 as my mail client, and I have assigned various categories to my mails.


In addition to searching for these categories within Outlook, I would like to include mail of a given category in various smart folders. Is there a way to use a raw query to return all mail assigned with a specific Outlook category?


Nigel

MacBook Pro with Retina display, OS X Mountain Lion (10.8.3)

Posted on Jan 19, 2014 3:51 AM

Reply
4 replies

Jan 19, 2014 6:25 AM in response to Nigel Smith1

Unless Microsoft has implemented a spotlight importer that grabs the information out of its database, I don't imagine it is possible. If you could grab a single message from Outlook and run mdls (metadata list) on it, you could see what metadata is stored. However, Outlook stores everything in a database, so grabbing a single item is kind of difficult.

Feb 13, 2014 11:52 AM in response to Nigel Smith1

Barney is right and there is no importer implemented. But having done this recently, it is not impossible. You do have to use mdls. First create an e-mail to yourself with something unique you can search on using spotlight. For example use a subject "xyz123" and maybe message content "test". After you receive the message in your inbox, delete a copy of the sent message in your sent folder. In your Inbox go to your test message that you just received and give it one category assignment. Now do the search in spotlight for "xyz123". You should only find one under the type "Mail & Messages" with title "xyz123". Open spotlight results in Finder. Do a Get info on the one item found. In the info box copy the entry in the "Where:" path field in its entirety (e.g., "/Users/yourname/Documents/Microsoft User Data/Office 2011 Identities/Main Identity/Data Records/Messages/0T/0B/0M/141K"). Now open your Terminal window. Type in cd "<path>". Make sure to enclose in parenthesis the path name else you get an error. You should now be in the directory where your message file is at. In your Get Info window, grab the "Name & Extension:" filename in its entirety (e.g., x00_141318.olk14Message) and do your mdls command to it in Terminal (e.g., mdls x00_141318.olk14Message). Look for the metadata com_microsoft_outlook_categories. This is the category ID for the category you had given your message. This is what you use in Raw Query (e.g., If you ID is 17, then your Raw Query is com_microsoft_outlook_categories == 17). Now if you want to search for other categories, you just go to your message and change its sole category to another. Then do another mdls command on it and you should get the category ID of this next category you used. Make sure you catalog these category and corresponding category IDs so you know all the cross references for future use. Not sure if and when Outlook does a massive change to this. But if it does you just have to update your cross reference chart and Raw Queries. So now if you want to do an OR search for multiple categories you use the OR command or operator (e.g., to search of ID 17 OR ID 121 you search for com_microsoft_outlook_categories == 17 || com_microsoft_outlook_categories == 121). In Outlook, the last category you assign to the message is the primary category (i.e., com_microsoft_outlook_primaryCategory). This dictates the color assigned to your message. You should see this listed in mdls output also. You can search for that as well. If you want to use a combined list of categories using the AND then use the && operator. Finally, to search beyond just one folder, you only have a choice of current folder or all mail. To specify this you click on the search tab and click on Folder or All Mail. Doesn't seem to give an option of subfolders. To add more to the query, you then click on the plus sign. For example to search for category ID 17 and the message "test" then you click plus and in Item Contains you enter test. Hope this helps.

How can I search for specific Outlook categories using raw query?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.