jdfwarrior Posted January 15, 2013 Share Posted January 15, 2013 Search Mail.app for email messages matching the search query passed. http://d.pr/f/FVd2 A few have reported with this not working so I went back and added the option in mdfind to search in a specific folder so that hopefully it would find those results. Report any issues UPDATE: Based on schoeps comment below, I realized that the search I was performing was queueing off of kMDItemKind == 'Mail Message' and depending on your local language, that may not be the appropriate value. So I changed it to search on kMDItemContentType which should be the same across the board. I have confirmed that it works in English and Italian at least. UPDATE: I removed the -onlyin argument from mdfind. Removing the specified folder helps in finding the files with alternate language OS's. drking, donparr, Weaselboy and 2 others 5 Link to comment
Enhorn Posted January 15, 2013 Share Posted January 15, 2013 Not getting any results. Is it restricted to the inbox? As I have a inbox zero right now, so that could explain it in that case. The account in question is an Exchange account, if that makes any difference. Link to comment
Filoumino Posted January 15, 2013 Share Posted January 15, 2013 Not working for me, too. I'm getting no results, no matter what I try. :-( Link to comment
drking Posted January 15, 2013 Share Posted January 15, 2013 I can't get it to work either. Link to comment
jdfwarrior Posted January 15, 2013 Author Share Posted January 15, 2013 Are you typing more than 3 characters? It doesn't start until there are 3 characters typed. It isn't restricted to Inbox. It finds in all folders, it's using mdfind to search for mail documents (.emlx files). I don't understand why it isn't working for some.. I've tested on all of my machines (iMac, Macbook Air, and Hackintosh), @binaryghost tested it, and a friend at work and it worked perfectly for all of us.. hrm.. Guess I'll keep trying. If anyone else has success, please let me know so I can confirm that I'm not going crazy Link to comment
schoeps Posted January 15, 2013 Share Posted January 15, 2013 Hi, it might be a language issue. On my German system mdfind -live "kMDItemKind == 'Mail Message' does not work, but mdfind -live "kMDItemKind == 'E-Mail'" returns plenty of mails. Link to comment
jdfwarrior Posted January 15, 2013 Author Share Posted January 15, 2013 Oh hrm.. thanks for the info.. I'll have to check and see if I can find the OS language and then adjust the query based on that Link to comment
rgalps Posted January 15, 2013 Share Posted January 15, 2013 Perhaps one of the reasons people think it doesn't work (apart from the language thing) is that it can take a while to return results - as the search is triggered for each key press, they can 'queue' up and your finial search query can take a while to be performed. My inbox has several hundred thousand messages in from across many folders, from mailing lists etc. While limiting the search to not kick in until 3+ characters has improved the speed, it's still slugish. Does Alfred have anyway of 'delaying' the execution of the workflow script, for say a few hundred milliseconds (configurable on the workflow)? That way searching for messages from "Jo blogs", the search won't actually start until you've finished typing - unless you are a really slow typer - but the results will appear almost instantly. I can see other benefits of this - especially on the extensions that go off to other web based APIs. Link to comment
jdfwarrior Posted January 15, 2013 Author Share Posted January 15, 2013 Guys, if you don't mind, I just posted a new version of it. Check the note in the first post about what I changed. Let me know if this fixes things. Thanks Link to comment
Filoumino Posted January 15, 2013 Share Posted January 15, 2013 Hmpf, still not getting any results. I tried search terms that definitely should be found and even waited some time. No luck here on a german system.But I really appreciate your restlessness :-) Link to comment
jdfwarrior Posted January 15, 2013 Author Share Posted January 15, 2013 Do me a favor? 1. Drop to a terminal. 2. Run: mdfind "kMDItemContentType == 'com.apple.mail.emlx'" Do you get results? If no, try mdfind -onlyin "<yourhomepath>/Library/Mail/V2/" "kMDItemContentType == 'com.apple.mail.emlx'" Results now? Link to comment
simonbs Posted January 15, 2013 Share Posted January 15, 2013 Thanks. Great workflow. Link to comment
donparr Posted January 15, 2013 Share Posted January 15, 2013 This is Great, David, thank you very much, this is timely, extremely useful and very much appreciated . Link to comment
Filoumino Posted January 15, 2013 Share Posted January 15, 2013 Do me a favor? 1. Drop to a terminal. 2. Run: mdfind "kMDItemContentType == 'com.apple.mail.emlx'" Do you get results? If no, try mdfind -onlyin "<yourhomepath>/Library/Mail/V2/" "kMDItemContentType == 'com.apple.mail.emlx'" Results now? Your first terminal command works and results in a lot of .emlx files as output! Link to comment
Weaselboy Posted January 15, 2013 Share Posted January 15, 2013 Thanks David. Nice job. Working perfectly here on 10.8.2. Link to comment
BaptistePANNIER Posted January 15, 2013 Share Posted January 15, 2013 I'm exactly in the same situation as Filoumino :/ Link to comment
jdfwarrior Posted January 16, 2013 Author Share Posted January 16, 2013 Your first terminal command works and results in a lot of .emlx files as output! Ok then we're getting somewhere. The second command is exactly what is used in the workflow. I was trying to target the exact area where the files were but maybe that is different in the alternate languages as well. I'll get a revision posted soon Link to comment
ithinkimalion Posted January 16, 2013 Share Posted January 16, 2013 Would it be possible to write this to work for something like PostBox? Link to comment
Enhorn Posted January 16, 2013 Share Posted January 16, 2013 I found out why this didn't work for me. "printf $HOME" results in my home folder path with a trailing "%". If I changed the home path line to "$home = str_replace('%','',exec('printf $HOME'));" the workflow started to work for me. I use ZSH as my standard shell, perhaps that is whats causing it, because I get no trailing "%" when i start BASH and run the command through that. Link to comment
jdfwarrior Posted January 16, 2013 Author Share Posted January 16, 2013 I found out why this didn't work for me. "printf $HOME" results in my home folder path with a trailing "%". If I changed the home path line to "$home = str_replace('%','',exec('printf $HOME'));" the workflow started to work for me. I use ZSH as my standard shell, perhaps that is whats causing it, because I get no trailing "%" when i start BASH and run the command through that. Ah, interesting. Glad you were able to figure it out. I haven't used ZSH in a while so I would have never caught that. Link to comment
fmr Posted January 22, 2013 Share Posted January 22, 2013 Thanks for a great workflow. The plugin seems to not work from time to time. When this happens, I find one of the following errors in /usr/log/system.log Jan 22 16:18:53 SCH-BP-2003.local Alfred 2[8287]: [ERROR] Script XML Parse Error occured Error Domain=NSXMLParserErrorDomain Code=26 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 26.)" or: Jan 22 16:10:34 SCH-BP-2003.local Alfred 2[8287]: [ERROR] Script XML Parse Error occured Error Domain=NSXMLParserErrorDomain Code=4 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 4.)" Link to comment
tconte Posted January 24, 2013 Share Posted January 24, 2013 Would it be possible to modify this to narrow the search using specific folders? i.e., search flagged mail OR search VIP mail. Thanks! drking 1 Link to comment
jdfwarrior Posted January 24, 2013 Author Share Posted January 24, 2013 Probably but I would have to add some kind of id for it to know what's what you were doing. For instance: Mail @flagged <search> Link to comment
cortig Posted January 31, 2013 Share Posted January 31, 2013 The Workflow sure works great for me, but I'm trying to understand your approach (and create other workflows on the same idea for other e-mail clients). Why use a script at all? Can the same thing be done with a filter? You can limit the scope to ~/Library/Mail/V2 and use the kMDItemAuthorEmailAddresses, kMDItemAuthors and kMDItemSubject metadata fields. What's wrong with that approach? I'm unsure how it all works, because I've ran into a few things I couldn't figure out when I tried (eg: using kMDItemContentType didn't seem to make any difference at all, that's why I eventually had to resort to limiting the scope). Corentin Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now