I need a way to automatically send responses to received email using Mail.app in OS X Leopard. Can any of you help me?
Here's how I want it to work (with the difficult parts in italics):
- A new message arrives.
- A Rule recognizes the new message as one that should get an autoresponse. (This part is easy; no need to tell me how to do this.)
- Mail.app generates a response message, using boilerplate text, but does not include the original message or attachments in the response.
- Mail.app sends the response message and leaves a copy of the sent message in a particular folder.
The standard approach to autoresponders in Mail.app is to set up a Rule that says "Reply to Message" and specifies message text. Unfortunately, that includes the full message plus all attachments in the reply, which I don't want. Also, it apparently makes the reply vanish, rather than putting it in the Sent folder.
The AppleScript provided by "Set up a Non-Quoting Autoresponder in Mac OS X Mail" seems like it ought to do more or less exactly what I want, but I can't get it to work. I installed it, I set up a rule to call it; the rule gets triggered properly; but the script doesn't run. It sets off some kind of crash log in the Console, filled with stuff I don't understand.
Also, Mac OS X Hints has an article that says that AppleScripts that generate a new Mail message won't run when called from a Rule in Leopard! They provide a wacky workaround in which the Rule calls a mini-AppleScript script that calls a shell script that calls the real AppleScript script. Horribly kludgy, but I'll live with it if I have to.
But I'm pretty sure that some other problem is happening that's preventing me from even getting to that problem.
As a test, I created the following script, put it in ~/Library/Scripts/Applications/Mail, and ran it from the Script-icon menu in Mail.app.
using terms from application "Mail" on run tell application "Mail" display dialog "Hello, world!" end tell end run end using terms from
That script works perfectly.
But if I change "on run" to "on perform mail action with messages" and try to call it from a Rule, it dies. Here's that version:
using terms from application "Mail" on perform mail action with messages theMessages for rule theRule tell application "Mail" display dialog "Hello, world!" end tell end perform mail action with messages end using terms from
When I open the AppleScript Dictionary for Mail.app and look up "perform mail action with messages", it looks pretty straightforward--and it looks like it's the right way (maybe the only way) to get a message or messages to operate on. But something sure isn't working.
Any ideas? I need to figure out some kind of answer by 9:00 p.m. California time tonight.
If all else fails, I may switch to sending an autoresponse when I enter stories into the database, rather than when the mail arrives. It'll take longer for the responses to go out (sometimes a couple of days), but at least that way authors can be certain that the story has actually made it into our database. We'll see.