Jump to content

Add support for mailmate email client


Recommended Posts

I have MailMate set as my default client, but navigating to a file in Alfred, then selecting "Email To" opens up Mail.app.

 

I assume that's because Alfred relies on Applescript and MailMate's Applescript support is weak?

Link to comment
Share on other sites

I have MailMate set as my default client, but navigating to a file in Alfred, then selecting "Email To" opens up Mail.app.

 

I assume that's because Alfred relies on Applescript and MailMate's Applescript support is weak?

 

Actually MailMate has pretty nice AppleScript support. I looked into it the other morning when kjf originally posted this. Alfred just doesn't support it yet because, well.. we didn't know about it, or at least I didn't. I had never heard of it until this post.

Link to comment
Share on other sites

Actually MailMate has pretty nice AppleScript support. I looked into it the other morning when kjf originally posted this. Alfred just doesn't support it yet because, well.. we didn't know about it, or at least I didn't. I had never heard of it until this post.

I'd love to know how you found the applescript support - when I looked at the dictionary it only had one custom command. It might be because I'm not super-familiar with Applescript, but I can't even figure out how you would grab a list of selected messages and do something with them.

Link to comment
Share on other sites

I'd love to know how you found the applescript support - when I looked at the dictionary it only had one custom command. It might be because I'm not super-familiar with Applescript, but I can't even figure out how you would grab a list of selected messages and do something with them.

 

Well, actually what I meant was that the AppleScript command to send a new email was extremely easy to use. There was only one command but it would easily allow for creating new mail messages, attaching files, etc. I ended up removing it so I can't quickly look back now, but I don't remember if there was a mechanism for being able to search through messages via AppleScript or not. I would think not. Something like searching the apps messages could potentially be done by reading an SQLite database or something though.

Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...
  • 3 weeks later...

Just to update this thread, I'm adding the ability to add custom AppleScript for open ended email support in the next release of Alfred. This means that users will be able to add support for additional mail clients which Alfred doesn't support by default :)

Is it possible to do so in the current version? How do I set MailMate as default client for sending files/attachements from Alfred?

Link to comment
Share on other sites

Is it possible to do so in the current version? How do I set MailMate as default client for sending files/attachements from Alfred?

 

It is possible - You'll need to craft the specific AppleScript support for MailMate as all mail clients are different. To get started, create a file called MailMate.applescript (or matching the name of your default Mail client) in the following folder in your home folder:

 

~/Library/Application Support/Alfred 2/Plugins/Email/

 

There should be a single AppleScript method in here which Alfred calls with the following format:

-- Send an email with an attachment
on send_email_with_attachment(ename, eemail, esubject, ebody, eattachment)
end send_email_with_attachment

To help, here is the full AppleScript used for Mail.app:

-- Copyright 2012 RunningWithCrayons. All rights reserved.

-- Send an email with an attachment
on send_email_with_attachment(ename, eemail, esubject, ebody, eattachment)
	tell application "Mail"
		activate
		
		set theMessage to make new outgoing message with properties {visible:true, subject:esubject, content:ebody}
		tell theMessage
			make new to recipient at end of to recipients with properties {name:ename, address:eemail}
		end tell
		tell theMessage
			repeat with aattachment in eattachment
				set filefn to (POSIX file aattachment) as Unicode text
				tell content
				  make new attachment with properties {file name:filefn as alias} at after last paragraph
				end tell
			end repeat
		end tell
	end tell
end send_email_with_attachment

It's worth remembering that eattachment is a list of attachments, not a single attachment, even if there is only one attachment.

 

Cheers,

Andrew

Link to comment
Share on other sites

It is possible - You'll need to craft the specific AppleScript support for MailMate as all mail clients are different. 

 

Benny from MailMate made the script for me. Works as expected.

Path of the file should be "~/Library/Application Support/Alfred 2/Plugins/Email/MailMate.applescript"

Here is the script:

-- Send an email with an attachment
on url_encode(theText)
	return do shell script "printf " & quoted form of theText & " | xxd -u -plain | sed 's/\\(..\\)/%\\1/g' | tr -d '\\n'"
end url_encode

on create_mailto(_subject, _body, _attachments, _email, _name)
	
	set _to to _email
	if (_name is not "") then
		set _to to _name & " <" & _email & ">"
	end if
	set _mailto to "mailto:?to=" & url_encode(_to) & "&subject=" & url_encode(_subject) & "&body=" & url_encode(_body)
	
	repeat with _attachment in _attachments
		set _filePath to POSIX path of _attachment
		set _mailto to _mailto & "&attachment-url=file://" & url_encode(_filePath)
	end repeat
	
	return _mailto
	
end create_mailto

on send_email_with_attachment(ename, eemail, esubject, ebody, eattachment)
	
	set _mailto to create_mailto(esubject, ebody, eattachment, eemail, ename)
	tell application "MailMate"
		open location _mailto with trust
		activate
	end tell
end send_email_with_attachment

or you can download the file from here.

Link to comment
Share on other sites

Not an issue.

Andrew, if there could be an option of selecting the email client to be used in Alfred preference, that would make it easier. 

 

This will likely happen in the future. At this point, I wanted to leave it as an advanced configuration as it's the first type of 'plugin' Alfred has had.

Link to comment
Share on other sites

  • 3 months later...
  • 5 years later...

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