Script to automatically email a file that is saved to a folder?


I am looking for someone who help me write a script (actually, write the script for me, since I don’t know much about scripts). I would like the script to automatically accomplish the steps below when the user saves or drags-and-drops a file into a specific folder:

a. Create a new email
b. Address the email to an address that is specified in the script/settings
c. Attach the file to the email
d. Make the subject of the email the filename of the file plus "(attached)"
e. Send the email
f. Move the file to a folder called "emailed to work"

Some of the code used in the application ‘attache’ could be helpful, I suppose.

Can any of you help me with this? Should I post this on another portion of this site or on rentacoder or somewhere? I apologize if I posted this in the wrong place.

Thank you,

Moved topic to the appropriate forum :slight_smile:


the proper place for this question is the AppleScript | OS X forum.
This forum is for sharing complete solutions.

Try this, change the property lines, save the script in ~/Library/Scripts/Folder Action Scripts and attach the script as folder action to the specific folder

property recipientAddress : ""
property recipientName : "John Doe"
property archiveFolder : "disk:path:to:emailed to work:"

on adding folder items to thisFolder after receiving theItems
	repeat with oneItem in theItems
		set {name:fileName} to info for oneItem
		tell application "Mail"
			set newMessage to make new outgoing message with properties {visible:true, subject:fileName & "(attached)"}
			tell newMessage
				make new to recipient at end of to recipients with properties {name:recipientName, address:recipientAddress}
				tell content to make new attachment with properties {file name:oneItem} at after the last paragraph
			end tell
			send newMessage
		end tell
		tell application "Finder" to move oneItem to folder archiveFolder
	end repeat
end adding folder items to

Martin - Sorry for posting to the wrong place.

Stefan - Thank you very much! The emails send just as I want them to. The first time I tried it the file was copied to the sent items folder, but after that first time they just sit in the folder into which I originally save them. Any ideas? Also, Can I send you a few $$ for your help? Do you use Paypal?