I'm trying to add the finishing touches to a Hazel rule that will create a new email, add the recipients details, populate it with predetermined text, attach a file, and send it. I've got everything nailed except for the file attachment. I've written my first AppleScript, and it works really well, except for that last little bit!

(To give you some context, I'm using the rule to send timesheets of my team to management, so the name of the file changes every month - eg. 'Marty McFly - Timesheet - 04112013' this week, but 'Marty McFly - Timesheet - 11112013' next week.)
Here's what I've got so far:
- Code: Select all
tell application "Mail" to activate
set recipientName to "Boss"
set recipientAddress to "boss@domain.com”
set theSubject to “Email Subject”
set theContent to "Hi there,
Please see attached file.
Cheers,
Chris
"
set theAttachment to "Macintosh HD:Users:WR:Downloads:Apple.eps"
tell application "Mail"
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
make new attachment with properties {file name:theAttachment} at after the last character
end tell
end tell
Is there an easy way to attach the file that triggered the rule to an email, either using Hazel or AppleScript?
Thanks everyone.
Chris