NOOB: Create mail message with PDF as att. PDF name in Subject

Hi all,

I’m new to Applescript but impressed by its possibilities. I want to get
a script to automate a tedious job that we do several times a day.

Here’s the story…
We create ads for different clients and we always send a PDF to the client
for approval. So every page has to be put in a mail message, with the PDF
name as subject.

What I’d like is a droplet that will create a new message to a defined recipient
and takes the name of the PDF (which is dropped on the droplet) and places
the filename in the subject line and attaches the PDF to the message.
I hope I can learn from this script and make adjustements so I can create droplets
for different recipients myself.

Any help is appreciated!


Eric (The Netherlands)


Here is a modified version of a droplet I use regularly, with some explanatory comments:

on open drop_file
	set bb to item 1 of drop_file --droplets treat all dropped items as a list.  This just tells the script to deal with the first item, which is the only item when a single file is dropped.
	set item_info to the info for item 1 of drop_file --Get the info about the dropped file
	set nom_fichier to the name of item_info --Get the name of the dropped file
	tell application "Mail"
		set b to make new outgoing message with properties {sender:"", subject:nom_fichier} --The sender needs to be the account in Mail that you want mail returned to.  The subject is the name of the file (see the [set nom_fichier] line above)
		tell b to make new to recipient
		set content of b to ((text returned of (display dialog "Message Today:" default answer ""))) & return & return --A simple input dialog to create content for the email message.  It is not necessary, or it could be set to a pre-written piece.
		tell b's content --Remember to reference the [b] variable
			make new attachment with properties {file name:bb} at after the last paragraph --Attaches the dropped file.
		end tell
		set address of first to recipient of b to "" --This is where you put the recipient's email address.  You could also make this an input dialog, or choose from a list, or something like that.
		send b
	end tell
end open

Save this as an Application from your Script Editor, and start dropping files on it. It works fine as it is, so long as you have real email addresses in the proper places.

Please post back with a report or further questions.

Hi Craig,

thnx for your help, this script does exactly what I want it to do!!!
I did some alterations - as you suggested - with sender, recipient
and content of the mail message and it WORKS LIKE A CHARM.

Thnx again, you’ll be seeing more of me here, great forum!


Glad to hear it, Eric.

Welcome to MacScripter.