[ re-posted for archival purposes ]
I live on (and off of) the UNIX command line, therefore using AppleScript is a bit of a mixed-bag experience for me. I’ve been using it since 1994, I think, but I have never grown to love it. It’s not the language that’s at fault but the spotty support for it. Still, it is decent enough to be useful, at least for some tasks. One of these is sending files to a pre-defined email address.
-- This script sends the file you select in
-- the file selection dialog to a pre-set
-- email address
-- Copyright (c) 2008 Jacek Artymiak
set theSubject to "Another File Forwarded from my Mac"
set theContent to "I'm forwarding this file from my Mac "
set theName to "Change this to the real recipient's name"
set theAddress to "you@example.com -- change this to a real destination address"
set theFile to choose file
tell application "Mail"
-- we need to check for new mail to 'wake up' Mail,
-- otherwise it will not send our message
check for new mail
-- here we set up our message
set theMessage to make new outgoing message with properties
{visible:false, subject:theSubject, content:theContent}
tell theMessage
make new to recipient at end of to recipients with properties
{name:theName, address:theAddress}
end tell
tell theMessage
make new attachment with properties {filename:theFile}
end tell
-- cross your fingers, we're about to send our message
send theMessage
end tell
Why not use the Automator? I tried, but for some reason I get strange errors. The example above works and forwards dozens of files daily to my project email account.