Jump to content

Mail.app search by author, subject or content [For macOS Mojave & earlier]


Recommended Posts

Thought I should share this workflow to search Mail.app :)

 

Use the following keywords to search:

  • emfrom to search the sender's name and email address
  • em for a general subject + content search
  • emsubj to search specifically for a subject line

 

You can download it here. Enjoy!

 

This version is suitable for both Alfred 3 and Alfred 4. 

 

Compatible with macOS versions up to Mojave.  Unfortunately, due to some changes made by Apple in macOS Catalina, it's no longer possible for third-party apps to access your Mail data. This may change in the future, but currently, using this workflow in Catalina or Big Sur will not return any results.

Link to comment

Not working. goes to fallback search after entering any word after keyword+space/enter.

 

Before you add a space, do you see "emsubj" show the "Search Mail.app by subject line" text with the Mail icon next to it?

Link to comment
  • 2 weeks later...

Before you add a space, do you see "emsubj" show the "Search Mail.app by subject line" text with the Mail icon next to it?

Thanks for creating this workflow. It seems to be half working for me. When I type emsubj, em, or, emfrom I see the text with the Mail icon next to it, but then as soon as I hit space, it defaults to the fallback searches. Just to make sure I have my other settings correct, what should be checked under Default Results and the user defined file types under Advanced?

 

Thanks in advance.

~Linnea

Link to comment

Thanks for creating this workflow. It seems to be half working for me. When I type emsubj, em, or, emfrom I see the text with the Mail icon next to it, but then as soon as I hit space, it defaults to the fallback searches. Just to make sure I have my other settings correct, what should be checked under Default Results and the user defined file types under Advanced?

 

Thanks in advance.

~Linnea

 

This is likely to be because no relevant items are returned; if there are no results at all, it'll switch to fallback searches.

 

Basic question but do you use Mail.app for your email? If you navigate to ~/Library/Mail/, what does it contain? The file filters need to be pointing to the right place, so if you have no emails stored there, you'll get the behaviour you're seeing.

Link to comment

Very nice, thank you.

Best Mail.app workflow I´ve seen.

 

But it doesn´t seem to show the results correctly sorted, based on the date it was received?

That would be absolutely awesome!

 

But nevertheless I will use this workflow very often! :)

Link to comment

how can i add a search for recipient ie the the messages I send to SOMEONE?  tried to add a filter and added 

 

"kMDItemRecipient" but does not work, whats the right syntax?

 

otherwise it works just fine

 

 

just found it:  it is kMDItemRecipients   and kMDRecipientsEmailAddresses   with an "s"

Edited by kw1
Link to comment

Very nice, thank you.

Best Mail.app workflow I´ve seen.

 

But it doesn´t seem to show the results correctly sorted, based on the date it was received?

That would be absolutely awesome!

 

But nevertheless I will use this workflow very often! :)

 

Any update on the sorting issue?  This is a great workflow, but not having the emails sorted by date does make this workflow less valuable.  For instance, I search for a subject, and the list returns a list of emails with the same or similar subject line (e.g., an email chain).  I know I want the latest email in the chain, but since the results are not in chronological order, things get messy.

Link to comment
  • 2 weeks later...

Any update on the sorting issue?  This is a great workflow, but not having the emails sorted by date does make this workflow less valuable.  For instance, I search for a subject, and the list returns a list of emails with the same or similar subject line (e.g., an email chain).  I know I want the latest email in the chain, but since the results are not in chronological order, things get messy.

 

There is no sorting as such as the workflow returns them in the order OS X feeds them back, but you can have a play with date ranges :)

 

You can create additional keywords and go to the file filter's advanced tab, where you can add a date range, e.g. one for today's mail, one for mail within the past 30 days. 

Link to comment
  • 3 weeks later...
  • 1 year later...

Would it be possible to list all unanswered Emails from one recipient or contact with this or another workflow?

 

I highly doubt that information is available as part of the metadata relating to an email; The metadata contains information about that particular message, not about its relationship to other messages, so it wouldn't be possible (as far as I know) to find out whether an email has been answered or not.

Link to comment

The workflow's no help to me, as I use MailMate, but I can't express how happy I am to see a workflow by you.

"Dogfooding" is by far the best way to create great products.

I'd love to see lots more workflows from you and Andrew, and if I could only have one "feature request" ever, it would be to have some workflows written by you guys.

Edited by deanishe
Link to comment

The workflow's no help to me, as I use MailMate, but I can't express how happy I am to see a workflow by you.

"Dogfooding" is by far the best way to create great products.

I'd love to see lots more workflows from you and Andrew, and if I could only have one "feature request" ever, it would be to have some workflows written by you guys.

 

Glad to see you're enjoying this one ;) I've created a bunch for internal use, and frequently create various hotkey and file filter-based workflows for users that are certainly nowhere near as exciting as the fantastic ones you've all been creating!

 

Please do keep bringing the best ones to my attention as I also love sharing them with users who are just beginning to discover how powerful workflows can be. In fact, my intention is to feature them more regularly on the Alfred blog, so expect to see more in the coming weeks! :)

 

Cheers, 

Vero

Link to comment
  • 7 months later...
  • 3 years later...
10 hours ago, Vero said:

 

@paulminors No problem, I've updated the link in the first post :)

 

You can also grab it here:

https://www.dropbox.com/s/5h3djhw2thf8xjp/Mail.app Search 3.0.alfredworkflow?dl=0

 

Cheers,
Vero

 

Thanks Vero, that's great! Is there a way to customise this so I could type my search e.g. "emfrom paul" and then hit enter to open Mail.app and go to the search results i.e. search bar is pre-filled with the query?

Link to comment

@paulminors This depends on whether Mail supports AppleScript for this, but this part is down to Mail's own functionality.

 

Alternatively, you could probably use a Dispatch Key Combo object, but this can be less reliable.  It's likely that another fellow forum member can help you with the AppleScript. :)

 

Cheers,
Vero

Link to comment
  • 3 weeks later...
On 3/29/2013 at 7:08 PM, Vero said:

 

This is likely to be because no relevant items are returned; if there are no results at all, it'll switch to fallback searches.

 

Basic question but do you use Mail.app for your email? If you navigate to ~/Library/Mail/, what does it contain? The file filters need to be pointing to the right place, so if you have no emails stored there, you'll get the behaviour you're seeing.

 

Thank you for the guide. I am also having a same issue. 

I found my ~/Library/Mail/ doesn't contain any files in it, however if I am using Mail.app, how can I move the actual email files to this library/mail/ folder? 

 

BR,

Sumin

Edited by sumin
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...