Applescript pinned to finder toolbar - mail attachment script

Hi again, I just read this article about pinning apps to your finder toolbar http://www.wired.com/gadgetlab/2013/10/finder-toolbar-app-shortcut/ and, having just gotten into applescript, tried pinning a script. IT WORKED! It’s in the toolbar right now. This is cool, right? It got me thinking…

What I want to do?
I’d really like to pin a script that takes any file dragged onto it and turns that into an email attachment of a new email (with a set subject, list of recipient emails (co-workers) and some stock text (maybe pop up a dialog for adding any extra necessary text (meetings, birthdays, etc) to the body of the email in version 2.0 of the script). It should be really useful for the weekly roster mailout for work.

What’s my problem?
I’m pretty sure I can handle the script for all of that (mail scripts seem especially well represented on the forums which helps) except the very start - I’ve only ever written folder action scripts and automator services so I have no idea how to tell a script “if I drag a file onto you, do this to it”.

I hate to be picky but…
There are a couple of workarounds that even I can see: simply creating a template draft in mail and just pinning mail.app to the finder toolbar would get me most of the way there; a folder action watching for a filename containing “Roster” would probably do it with what I already know (though I usually version from the previous weeks roster so I have a template for the one I’m doing, so I would have to change my creating/saving routine or a folder-add action would send out the wrong week’s roster).
I sort of want to learn how to do it the way I describe above though, partly because I’m stupid stubborn and partly because it seems like a useful trick I could learn to use for other scripts down the line. I have this other idea with… no. One idea/post/thread at a time :confused:

Thanks for having a look a my question, and thanks in advance for any suggestions (I can guess it’s not the most complex and stimulating of problems for experienced applescripters)
nec

Just in case anyone else is as noob as I am and looks for this - an Applescript that’s used this way is called a “droplet” (that was the missing piece of information that would have hastening my forum searching) Turns out I not only don’t know how to ask a mac to do something with applescript, but I don’t know how to ask a search engine about how to ask a mac to do something with applescript).

There’s a basic intro and a couple of examples at http://www.macosxautomation.com/applescript/sbrt/sbrt-10.html

Code coming but not yet because sleep
nec

Hi NeverEnoughCoffee,

A droplet has an open handler something like this:

on open these_files
	-- your stuff here
end open

The variable these_files is a list of references to files dropped.

Edited: you save it as an application.

Edited: I also should have called it these_items, because they could be folders.

gl,
kel

Here’s a link from this site for info on handlers:
http://macscripter.net/viewtopic.php?id=24743

gl,
kel