Jump to content

MailTo: Select multiple Contacts *and* Groups and compose in your favourite email app


Recommended Posts

2015-07-29: Version 2 released
 
MailTo: Select multiple Contacts and/or Groups, and compose in your favourite email app
 
Search your Contacts and compose an email to one or more recipients (or none) in your preferred email program. Also supports Groups.
 
The main aim—versus Alfred's built-in, more comprehensive contact handling—is to make it fast and easy to select multiple recipients and especially groups.
 
demo.gif

Features

  • Search and add recipients from your Contacts database
  • Send to Groups/Distribution Lists (they're the same thing)
  • Also enter email addresses by hand
  • Use any email client you want (uses system default as standard)
  • Results prioritised by order of email addresses in Contacts

Download/Installation
 
Grab your copy from GitHub or Packal. Install in the usual fashion.
 
Usage
 
Keyword is @

  • @ + ENTER — compose a blank mail (no recipients)
  • @ [part of name or email address] — search your Contacts for matches. You can also add email addresses not in your Contacts.
    • ENTER/⌘+NUM — add selected email address to recipient list and go to email program
    • TAB — add selected email address to recipient list and continue searching
  • mailto — see and change current settings
  • If you've entered an invalid email address, it will be removed from the recipient list when your email app is called.

Supported apps
 
In theory, MailTo should work with any email client (it uses the mailto: protocol).
 
Tested and working with:

  • Airmail 1
  • Airmail 2
  • Apple Mail
  • Sparrow
  • Thunderbird
  • Postbox
  • Airmail (email addresses only)
  • Unibox
  • MailMate
  • Mailbox Beta (email addresses only)
  • MS Outlook
  • Google Chrome (if you've set a handler)
  • Fluid single-session browsers

Does not work with:

  • Safari (it will just open your system default email client)

More info
 
Please see the documentation.
 
Note on Groups
 
When deciding which email address to use for members of Groups, MailTo will use the one you've specified, or then the primary email address for the contact (don't ask me how to set that; I haven't been able to figure it out), and then the first one in their list of email addresses.
 
To specify which address to use for a contact in a Group, open Contacts and go to Edit > Edit Distribution List …
 
Changelog
 
2013-10-31

  • Add recipient name when calling email client, i.e. "Bob Smith <bob.smith@example.com>" instead of just "bob.smith@example.com".

2013-11-01

  • Add support for Groups
  • Prioritise email addresses by primary status then order in Contacts
  • Change ID (cache format has changed)
  • Use MIT licence

2013-11-03

  • Change config keywords to mailtoconf and mailtohelp so they don't get mixed in with search results from the default mailto action.

2013-12-03

  • Properly format the mailto: URL so workflow works correctly with MailMate.

2013-12-06

  • Added built-in, app-specific support for the email clients listed above. They should now work flawlessly without any need to edit settings. Note: the settings format has changed, so all your settings (yes, both of them) have been reset. There should be no need to edit them if you're using MailTo with your default system email client.

2014-03-24

  • Fix plist parsing problems.

2014-09-13

  • Add support for Mailbox Beta
  • Add new keyword @

2015-07-29

  • Release V2
  • Supports more types of contact accounts
  • Supports more email clients
  • Users can add support for their own clients

2016-02-10

  • Add support for MS Outlook
  • Add support for Airmail 2
  • Remove duplicates based on name and email address
Edited by deanishe
Link to comment

Same issue with Mavericks (and Airmail Meta btw). Can open a blank email but can't lookup contacts. :(

I reckon this has to do with the new security features in Mavericks where it asks if you can access contacts and this script goes straight to the SQLite database which I expect is a no-no . . . just a guess . . .

Edited by rudders
Link to comment

Tested with OSX Lion 10.8.5. and airmail (previously set as system default email client)

 

Composing blank mail is ok.

 

No contact is showing up when typing part of the address mail....

I allowed Alfred + Airmail to access my Contacts.

Edited by politicus
Link to comment

Righty. I tested it on another machine and it was (probably) just a really dumb coding error that wouldn't trigger on an OS install as crufty and old as mine. It should work now for Mountain Lion users. Possibly for Mavericks users, too, but I can't test that yet.

 

I've uploaded a corrected version at the same URL.

Link to comment

Righty. I tested it on another machine and it was (probably) just a really dumb coding error that wouldn't trigger on an OS install as crufty and old as mine. It should work now for Mountain Lion users. Possibly for Mavericks users, too, but I can't test that yet.

 

I've uploaded a corrected version at the same URL.

 

Working now. Nice work

Link to comment

Splendid.

 

I've changed it again so it also includes the names of the folks you're mailing (if available), i.e. "Bob Dole <bob@aol.com>" instead of just "bob@aol.com". I'd guess this is the preferred behaviour.

 

Please let me know if I've broken it  again  :)

Edited by deanishe
Link to comment

Is there a way to send an email to more than one contact with your workflow?

 

Sure. That's kind of the whole point. I'll try to make that clearer in the original post.

 

Be sure to TAB on a contact to add it to the list of recipients (not ENTER). The email will be added to Alfred's search field, plus a comma. Then just start typing the next name/email. TAB again to add that one, or hit ENTER (or ⌘+NUM) to add the selected contact and start composing your mail.

 

I'm going to have a crack at contact groups next.

Edited by deanishe
Link to comment

this is so handy. thanks for the workflow.

is there a way to show always the mail address I used last?

i.e. A contact hast three mail addresses but I only use the private one. So when I next use "mailto john" the last used mail address is first.

 

Thanks again.

Link to comment

That would definitely be a useful feature, and I'll have a think about how it could be best implemented. (The only idea I've had so far would entail a significant re-write.)

 

As things stand, results based on contact names (not addresses) will show the email addresses in the same order as they are listed in Contacts, except the primary email address (the starred one) should always be at the top.

 

So you could try making sure your preferred email address is the first one listed on the contact's card in Contacts. That would have the added bonus of having the same effect in Mail.app (unfortunately, other email clients aren't so smart).

 

I realise that might mean a lot of mindless work if there are a lot of affected contacts, so I will see what I can do.

Edited by deanishe
Link to comment
  • 3 weeks later...

Alfred is already incredibly helpful on its own, but workflows such as yours make it even more unbelievable. Thanks for your work!

Just wondering if there's a way to segregate emails by To: Cc: and Bcc: ?

 

Working fine with Mavericks and Airmail, too, by the way.

 

I reckon it would be possible to add, say, cc or bcc as one of the recipient addresses and all subsequent emails would go to that field., e.g. bob@example.com, sue@example.com, cc, harry@example.com, bcc, boss@example.com. In this case, harry@example.com would be cc'ed and boss@example.com would be bcc'ed.

 

I will look into it.

Link to comment

It looks like this extension does parse all contact accounts. I have both gmail and exchange set up and it doesn't find any of my exchange contacts.

 

I guess you mean "doesn't", which is true: it only looks at native Address Book databases, i.e. your local Mac contacts and your iCloud contacts.

 

I am investigating other ways to access the Address Book database (the official way is extremely slow from Python, so I didn't use it), but I don't have an Exchange account to test it with. A Gmail account should work because it's synchronised with your local Mac contacts database (not iCloud), so the workflow should pick those contacts up.

 

I'll put together a test script that uses the official API. Perhaps someone with an Exchange account could run it and let me know if it finds Exchange contacts. From what I've read, it should work, but I'd like to be sure before I rewrite the workflow, especially because the API is 10x slower than the current implementation …

Link to comment

I guess you mean "doesn't", which is true: it only looks at native Address Book databases, i.e. your local Mac contacts and your iCloud contacts.

 

I am investigating other ways to access the Address Book database (the official way is extremely slow from Python, so I didn't use it), but I don't have an Exchange account to test it with. A Gmail account should work because it's synchronised with your local Mac contacts database (not iCloud), so the workflow should pick those contacts up.

 

I'll put together a test script that uses the official API. Perhaps someone with an Exchange account could run it and let me know if it finds Exchange contacts. From what I've read, it should work, but I'd like to be sure before I rewrite the workflow, especially because the API is 10x slower than the current implementation …

 

Yep. I just fixed my post. Sorry about that. I'd be willing to test if you want to send it over.

Link to comment

Righty, I've uploaded the script here. Either copy-paste it into a new file or download it. Then run the script in Terminal with:

 

python ABSearch.py 'name'

 

If that throws an error, try

 

/usr/bin/python ABSearch.py 'name'

 

whereby name is the name or email address (or part thereof) of one of your contacts. Check the output to see if it's including contacts from your Exchange account as well as your Mac/iCloud accounts.

 

Also note the speed of the script (i.e. really slow). Even if it does find all the contacts, it might not be possible to make it run fast enough to be useable with a large contacts database.

Link to comment

Righty, I've uploaded the script here. Either copy-paste it into a new file or download it. Then run the script in Terminal with:

 

python ABSearch.py 'name'

 

If that throws an error, try

 

/usr/bin/python ABSearch.py 'name'

 

whereby name is the name or email address (or part thereof) of one of your contacts. Check the output to see if it's including contacts from your Exchange account as well as your Mac/iCloud accounts.

 

Also note the speed of the script (i.e. really slow). Even if it does find all the contacts, it might not be possible to make it run fast enough to be useable with a large contacts database.

 

 

I just tried it and it seems like it works great for both my Gmail and Exchange contacts. And it was pretty fast. didn't feel slow at all. Here's one example which included contacts from both Gmail and Exchange:

 

python ABSearch.py 'Tom'

5 results for 'Tom' in 0.1642 seconds

Edited by Jb_Bryant
Link to comment

0.1642 seconds is pretty fast when you're running a shell script once, but Alfred calls it (if it can) every time you type a letter. In those terms, it's really rather slow. (And it runs much slower still when Alfred is calling it to search for just one or two letters.)

 

By way of comparison, using a query that takes a similar length of time on my computer (0.1541 s), the original workflow's search takes 0.002 s, and it's doing more work (searching groups, too).

 

I've made a test workflow for the all-accounts search here. Give it a try and see what you think of the performance.

 

I'll work on speeding it up as much as I can, but if I can't get it at least 10-20x faster, I'll make it an option/separate workflow.

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...