Jump to content

Default email client when sending files


Recommended Posts

I use Nylas email client.

 

When I use the build-in function to send email through my default client (https://i.imgur.com/QNHsfIB.png), it works fine in Nylas (https://i.imgur.com/wxykDqo.png).

 

But when I want to email selected file (https://i.imgur.com/WZ2e7Uj.png), it don't use my set default email client but opens the native mail app :((https://i.imgur.com/eDsMlNR.png).

 

 

When simply sending an email, Alfred uses mailto: and lets OS X use the default mail client. Meanwhile, when attaching files, some AppleScript is required, so we include support for the most common email clients, and allow you to add custom scripts for other clients.

 

I've not heard of Nylas before, but if it supports AppleScript, you should be able to create your own script (or ask friendly people on the forum to help you out) and drop it here:

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

 

You'll then be able to use that mail client as your default client for attaching files.

 

I'll move this to Discussion & Help so that others can see it & help you with your script if needed :)

 

Cheers,

Vero

Link to post
  • 1 month later...

I would be very interested to see how this would work. I've installed a plugin that should redirect mailto: links to gmail, (in safari, my browser) but I have no clue how to create an applescript to add to the ~/Library/Application Support/Alfred 2/Plugins/Email/

 folder.... any help would be much appreciated
Link to post
  • 1 month later...

Your best bet is to look at an existing plugin and try to adapt that to your email program.

 

The precise implementation will depend on your email program's API, however.

 

May you point us to one of such existing plugins, I would really appreciate it, thank you

Link to post

Try looking in Alfred's data directory on your machine. I think there may be a bundled one.

The ones posted on the forum disappeared because the fella who wrote them (David) hosted them on Droplr or something else temporary. It's possible they've been re-hosted.

If you can't find one, I'll paste the one I have here (I'm not at my computer right now).

Link to post
  • 1 year later...

Hi folks.

 

I'm curious as to how to set this up as well.

 

I'm using Spark as my default email client and would love to be able to select a file in finder and email it off using alfred's Actions.

 

I looked in my plugins folder and there are no bundled plugins for my alfred 3 installation.

 

Thank you!

 

sam.

Link to post
4 hours ago, samlimster said:

I'm using Spark as my default email client

 

The first question to answer is whether Spark actually provides a mechanism to programatically add attachments (via AppleScript or a URL scheme etc.). If it doesn't, you can forget about it.

 

Link to post
  • 4 months later...
On 9/12/2017 at 6:01 PM, deanishe said:

 

The first question to answer is whether Spark actually provides a mechanism to programatically add attachments (via AppleScript or a URL scheme etc.). If it doesn't, you can forget about it.

 

 

When I use mail.app search workflow, if I use spark as the application to open a file, the file becomes an attachment in spark. Not sure if that's something related or helpful at all.

 

I'm new to Alfred workflow.

 

Link to post

I was intrigued by how to create an email plugin, so I had a look to create one for Spark... Here's what I've found to be the most robust way to make it work with Alfred. In short, I'm combining the script for MailMate found here and @Shana601 way by opening files in Spark (using a do shell script since it seemed to be more robust than the applescript open). I've found that multiple opening of files append the files to the attachment. Therefore, I'm opening a mailto: link to set the emails, subject and body and then another open for the files to be attached.

 

Here is the file/plugin to put into your "~/Library/Application Support/Alfred 3/Plugins/Email/" folder: https://d.pr/f/jSrHh3

 

Here is the script:

-- Use Spark as default email application with Alfred
-- Based on MailMate plugin script: https://www.alfredforum.com/topic/2354-add-support-for-mailmate-email-client/

-- 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, _email, _name)
	set _to to _email
	if (_name is not "") then
		set _to to _name & " <" & _email & ">"
	end if
	return "mailto:?to=" & url_encode(_to) & "&subject=" & url_encode(_subject) & "&body=" & url_encode(_body)
end create_mailto

on send_email_with_attachment(ename, eemail, esubject, ebody, eattachment)
	set _mailto to create_mailto(esubject, ebody, eemail, ename)
	tell application "Spark"
		activate
		open location _mailto with trust
	end tell
	repeat with attachment in eattachment
		do shell script "open -a Spark \"" & attachment & "\""
	end repeat
end send_email_with_attachment

 

Edited by GuiB
Updated download link
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
×
×
  • Create New...