Jump to content


Photo

Search Mail.app Workflow


  • Please log in to reply
35 replies to this topic

#1 David Ferguson

David Ferguson

    Alfred Guru

  • Staff
  • 1,885 posts
  • LocationHuntsville, AL

Posted 15 January 2013 - 02:12 AM

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.


  • donparr, Weaselboy, drking and 2 others like this
Twitter: jdfwarrior | Blog: dferg.us

#2 Enhorn

Enhorn

    Member

  • Member
  • PipPip
  • 26 posts
  • LocationStockholm, Sweden

Posted 15 January 2013 - 07:47 AM

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.



#3 Filoumino

Filoumino

    Newbie

  • Member
  • Pip
  • 6 posts
  • LocationRostock, Germany

Posted 15 January 2013 - 08:21 AM

Not working for me, too. I'm getting no results, no matter what I try. :-(  



#4 drking

drking

    Member

  • Member
  • PipPip
  • 47 posts
  • LocationLouisiana, USA

Posted 15 January 2013 - 09:21 AM

I can't get it to work either.  



#5 David Ferguson

David Ferguson

    Alfred Guru

  • Staff
  • 1,885 posts
  • LocationHuntsville, AL

Posted 15 January 2013 - 11:40 AM

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


Twitter: jdfwarrior | Blog: dferg.us

#6 Sebastian

Sebastian

    Member

  • Member
  • PipPip
  • 53 posts

Posted 15 January 2013 - 12:21 PM

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.



#7 David Ferguson

David Ferguson

    Alfred Guru

  • Staff
  • 1,885 posts
  • LocationHuntsville, AL

Posted 15 January 2013 - 12:45 PM

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


Twitter: jdfwarrior | Blog: dferg.us

#8 rgalps

rgalps

    Newbie

  • Member
  • Pip
  • 7 posts

Posted 15 January 2013 - 01:05 PM

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. 



#9 David Ferguson

David Ferguson

    Alfred Guru

  • Staff
  • 1,885 posts
  • LocationHuntsville, AL

Posted 15 January 2013 - 02:00 PM

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


Twitter: jdfwarrior | Blog: dferg.us

#10 Sebastian

Sebastian

    Member

  • Member
  • PipPip
  • 53 posts

Posted 15 January 2013 - 02:07 PM

Great, works for me!



#11 Filoumino

Filoumino

    Newbie

  • Member
  • Pip
  • 6 posts
  • LocationRostock, Germany

Posted 15 January 2013 - 05:17 PM

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 :-) 



#12 David Ferguson

David Ferguson

    Alfred Guru

  • Staff
  • 1,885 posts
  • LocationHuntsville, AL

Posted 15 January 2013 - 06:15 PM

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?


Twitter: jdfwarrior | Blog: dferg.us

#13 simonbs

simonbs

    Member

  • Member
  • PipPip
  • 47 posts

Posted 15 January 2013 - 06:18 PM

Thanks. Great workflow.



#14 donparr

donparr

    Newbie

  • Member
  • Pip
  • 5 posts
  • LocationSouthern California

Posted 15 January 2013 - 10:01 PM

This is Great, David, thank you very much, this is timely, extremely useful and very much appreciated  :) .



#15 Filoumino

Filoumino

    Newbie

  • Member
  • Pip
  • 6 posts
  • LocationRostock, Germany

Posted 15 January 2013 - 11:08 PM

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!



#16 Weaselboy

Weaselboy

    Member

  • Member
  • PipPip
  • 45 posts

Posted 15 January 2013 - 11:33 PM

Thanks David. Nice job. Working perfectly here on 10.8.2.



#17 Baptou

Baptou

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 15 January 2013 - 11:38 PM

I'm exactly in the same situation as Filoumino :/



#18 David Ferguson

David Ferguson

    Alfred Guru

  • Staff
  • 1,885 posts
  • LocationHuntsville, AL

Posted 16 January 2013 - 12:51 AM

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
Twitter: jdfwarrior | Blog: dferg.us

#19 ithinkimalion

ithinkimalion

    Newbie

  • Member
  • Pip
  • 7 posts

Posted 16 January 2013 - 05:43 AM

Would it be possible to write this to work for something like PostBox?



#20 Enhorn

Enhorn

    Member

  • Member
  • PipPip
  • 26 posts
  • LocationStockholm, Sweden

Posted 16 January 2013 - 07:58 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users