Jump to content
deanishe

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

Recommended Posts

I use Airmail and i was having problems with the "mailto" option. it was pulling the contact and plugging in <name <name@mail.com>> in the To: field. As this is not a valid e-mail address format I was having to change it manually. If you are having the same problem, I modified line 123 in the mailto.py code.

 

it should read:

 

return u'{}'.format(email)

 

this now places the correct format in the To: field

 

name <name@mail.com>

 

hope this helps someone.

 

 

 

Share this post


Link to post

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.

 

It is a little slower but I don't mind personally just because it does what I need. Others may disagree though. I did my best to show you the speed without showing you my contacts' details:

 

http://cl.ly/1I2t1l3K251m

Share this post


Link to post

I use Airmail and i was having problems with the "mailto" option. it was pulling the contact and plugging in <name <name@mail.com>> in the To: field. As this is not a valid e-mail address format I was having to change it manually. If you are having the same problem, I modified line 123 in the mailto.py code.

 

it should read:

 

return u'{}'.format(email)

 

this now places the correct format in the To: field

 

name <name@mail.com>

 

hope this helps someone.

 

The problem is a known one.

 

There's no need to change the code, just run mailtoconfig in Alfred and either specifically set Airmail as your client (the workflow knows Airmail only accepts email addresses, no names) or change the format to Email Only.

 

This is no longer true. The workflow can now discover which email client you have set as system default and adjust its output accordingly.

 

Note: the workflow will still send Name and Email if you've specifically set that format.

 

I've updated the original post to draw attention to this problem.

Edited by deanishe

Share this post


Link to post

It is a little slower but I don't mind personally just because it does what I need. Others may disagree though. I did my best to show you the speed without showing you my contacts' details:

 

http://cl.ly/1I2t1l3K251m

 

I'll see what I can do. Thing is, it's going to get slower: it needs to search groups, too, which it isn't currently doing.

 

Ideally, I'd be able to cache the contacts database like I do now, but it takes 3–5 seconds to load all contacts this way vs 0.05 seconds the current way.

Share this post


Link to post

*bump*

 

Another update. No new features as such, but now recognises which email client you're using (i.e. no need to set one in the workflow), and comes with fairly robust support for most of the popular Mac email clients. That is to say, no more problems with Airmail, MailMate or contacts with commas or diacritics in their names.

 

If your email client of choice isn't listed in the OP and/or isn't working properly, please let me know.

 

Obviously, that applies to problems with listed email clients, too  ;)

Share this post


Link to post

I use Airmail and i was having problems with the "mailto" option. it was pulling the contact and plugging in <name <name@mail.com>> in the To: field. As this is not a valid e-mail address format I was having to change it manually. If you are having the same problem, I modified line 123 in the mailto.py code.

 

it should read:

 

return u'{}'.format(email)

 

this now places the correct format in the To: field

 

name <name@mail.com>

 

hope this helps someone.

 

Fairly hefty update today. Any and all problems with Airmail should be things of the past.

Share this post


Link to post

Fairly hefty update today. Any and all problems with Airmail should be things of the past.

This is a wonderful workflow.

 

What would be extra specially great would be to select the account it was being sent from. I have 3 email addresses I use so it would be great to say "mailto paul with acct1name"

 

Is this possible?

Share this post


Link to post

I'm afraid that's not possible, as it isn't supported by the mailto protocol the workflow uses.

 

Some email clients enable you to specify a sender when called via AppleScript, but they don't provide a way to see which sender addresses they know about …

Share this post


Link to post

How do you install this workflow? Mine doesn't work. It installs fine, but when I type mailto and then enter it does nothing. Is there another software I need to install first? 

Share this post


Link to post

If you're still worried about speed on the Exchange contacts query, then consider putting in a minimum number of characters to search before the script filter "fires." I.e. if the "argument" has fewer than three characters, return some xml that says "type more characters to search" or something. Then it won't grab quite as many results (results for the "t" would be much bigger and slower than "tom"), and it won't get caught up doing those first two searches, making the overall thing faster.

 

If you want to get much, much fancier, then you could consider caching the query results for some amount of time.

Share this post


Link to post

nothing is happening with me. I downloaded the file double click to install and try it but I don't know what is going on it just shoots me to a blank webpage (I'm using Safari) any help.

Share this post


Link to post

nothing is happening with me. I downloaded the file double click to install and try it but I don't know what is going on it just shoots me to a blank webpage (I'm using Safari) any help.

 

I just downloaded the workflow myself using Safari and it installed just fine. Could you verify that you're downloading a file called "MailTo.alfredworkflow" that is 197 KB in size?

Share this post


Link to post

If you're still worried about speed on the Exchange contacts query, then consider putting in a minimum number of characters to search before the script filter "fires." I.e. if the "argument" has fewer than three characters, return some xml that says "type more characters to search" or something. Then it won't grab quite as many results (results for the "t" would be much bigger and slower than "tom"), and it won't get caught up doing those first two searches, making the overall thing faster.

 

If you want to get much, much fancier, then you could consider caching the query results for some amount of time.

 

The problem is that even with 3+ character queries, search takes ~0.2 seconds, which I consider to be unacceptably slow. I imagine a lot of people have significantly more contacts than I do, too.

 

At the moment I'm experimenting with re-writing the workflow in Objective-C to get full speed out of the native API. Unfortunately, it's still a lot slower than the current implementation and the search is far more rudimentary.

 

Are there any volunteers who I could send a proof-of-concept version to, so they can confirm whether it works with Exchange contacts, too? The Apple API docs say:

 

 

Note: You can only search the user’s local Address Book database, not remote directories such as CardDAV or Exchange.

 

However, Jb_Bryant reported that his Exchange contacts were showing up in the Python version that uses the official API (via a bridge).

Edited by deanishe

Share this post


Link to post

Would there be any way to use Gmail in Chrome as the default method with this workflow? That way I could use Outlook as my default system-wide and use the built in contact search in Alfred for that. And then use this workflow to send through Gmail since all of my iCloud and Gmail contacts show up with this workflow.

Share this post


Link to post

I see now that in your original post it says it should work if you choose Chrome as the mail client. That didn't work in the old workflow. It would just open up a blank tab in Chrome. I just upgraded to the latest version and it actually doesn't work at all. I type mailtoclient, hit enter, and it goes to my fallback google search.

Share this post


Link to post

Have you enabled Gmail as an email client yet? It won't work if you haven't done that.

 

I'm afraid I can't replicate the mailtoclient error. What happens when you TAB on it?

Share this post


Link to post

To enable Gmail, open it in Chrome and hit the overlapping squares icon in the location bar.

 

With regard to the configuration problem, could you open the workflow directory in Terminal and run:

python mailto.py client

If you could PM me the output, I can try to fix it.

 

If there is no output, run:

python mailto.py logon

Then once more:

python mailto.py client

And finally:

python mailto.py openlog

And PM me the contents of the log instead.

Share this post


Link to post

The plutil parsing of com.apple.LaunchServices.plist fails on my system with an error "invalid object in plist for destination format". My file contains a '<data>' field for the LSHighResolutionModeIsMagnified key.

Share this post


Link to post

Jb_Bryant is having similar problems. It's an Apple utility choking on an Apple file …

I'm looking into a workaround. Thanks for the feedback.

Edited by deanishe

Share this post


Link to post

The plutil parsing of com.apple.LaunchServices.plist fails on my system with an error "invalid object in plist for destination format". My file contains a '<data>' field for the LSHighResolutionModeIsMagnified key.

 

Had a poke around, and it looks like exporting the plist as XML, not JSON, should fix the problem. I'll try and get that changed tomorrow (well, later today, I guess) and upload a new version.

 

Thanks for the testing and explicit error message. It was very helpful.

Share this post


Link to post

Is there any update on this? I really need this workflow really bad. Here's my output if it helps.

 python mailto.py client

Traceback (most recent call last):
  File "mailto.py", line 62, in <module>
    from contacts import get_contacts, CACHEPATH
  File "/Users/G/Dropbox/Alfred2/Alfred.alfredpreferences/workflows/user.workflow.7E8973CB-6BB8-4137-B64E-1480BAE6661E/contacts.py", line 29, in <module>
    log = logger(u'contacts')
  File "/Users/G/Dropbox/Alfred2/Alfred.alfredpreferences/workflows/user.workflow.7E8973CB-6BB8-4137-B64E-1480BAE6661E/log.py", line 24, in logger
    s = Settings()
  File "/Users/G/Dropbox/Alfred2/Alfred.alfredpreferences/workflows/user.workflow.7E8973CB-6BB8-4137-B64E-1480BAE6661E/settings.py", line 49, in __init__
    self._load()
  File "/Users/G/Dropbox/Alfred2/Alfred.alfredpreferences/workflows/user.workflow.7E8973CB-6BB8-4137-B64E-1480BAE6661E/settings.py", line 60, in _load
    self['system_default_app'] = self._get_system_default_client()
  File "/Users/G/Dropbox/Alfred2/Alfred.alfredpreferences/workflows/user.workflow.7E8973CB-6BB8-4137-B64E-1480BAE6661E/settings.py", line 75, in _get_system_default_client
    d = json.loads(check_output(command))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 575, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '[u'plutil', u'-convert', u'json', u'-o', u'-', u'/Users/G/Library/Preferences/com.apple.LaunchServices.plist']' returned non-zero exit status 1

Share this post


Link to post

@dpyy: I had the same problem and I have rebuild the com.apple.LaunchServices.plist file (delete and restart the mac). After this I had to re-set some settings, but it works.

Share this post


Link to post

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
×