I am trying to set up an auto reply in Mac Mail that includes an attachment. I can get the auto reply to work with the text message but not with the attachment. I am trying to use applescript but I’m not really that familiar with it. I’ve tried:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
try
set theAttachment to "Macintosh HD:Users:Dan:Documents:Papers2:Hocking:2013:Articles:Hocking_2013_Forest_Ecology_and_Management.pdf"
set theBody to "Hi - attached you will find out paper, Effects of experimental forest management on a terrestrial, woodland salamander in Missouri, which you requested. If you believe you received this email without solicitation please let me know at dhocking@unh.edu.
I hope you find our paper useful!
-Dan TEST"
repeat with eachMessage in theMessages
tell application "Mail"
tell eachMessage
set {theSender, theAddress, theSubject} to {extract name from sender, extract address from sender, subject}
end tell
set newMessage to make new outgoing message with properties {subject:"Re: " & theSubject, content:theBody, visible:true}
tell newMessage
make new to recipient at end of to recipients with properties {name:theSender, address:theAddress}
tell content to make new attachment with properties {file name:theAttachment as alias} at after the last paragraph
end tell
activate
send newMessage
end tell
end repeat
on error m number n
display dialog "Error: " & m
tell application "Mail"
log "Exception in Mail action: (" & n & ") " & m
end tell
end try
end perform mail action with messages
end using terms from
I set the rule under Mail > Preferences based on a specific subject line. Then added this applescript to the rule. When I send a test email, it auto replies with the appropriate text body but there is no attachment. I’m sure I’m missing something simple but I’ve never used an applescript before, so clearly I’m missing something. Any help would be appreciated. I’m using Mail v6.2 on Mac OS 10.8.
I copied theAttachment directory path into my browser with / instead of : and it opened the file, so mis-specification of the path doesn’t seem to be the problem.
Model: MacBook Pro
AppleScript: 2.2.3
Browser: Firefox 18.0 AlexaToolbar/amznf-3.0.20121002
Operating System: Mac OS X (10.8)