This is a question which was posted at Japanese Apple’s Discussion Board.
He’d like to do as follows.
When a new mail which matches some rules arrives, make a reply with default citation and signature and
keep this reply mail into Drafts mailbox.
I tested a following script for rule action.
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
repeat with eachMessage in theMessages
save (reply eachMessage with reply to all)
end repeat
end tell
end perform mail action with messages
end using terms from
I found this script works well in Panther(10.3.9) but does not in Tiger(10.4.4). I have an unexpected result as follows.
Nothing occurs at a new mail arrival.
I quit Mail.app and launch again, then a reply window appears for the the mail above.
Is this a bug of Mail.app in Tiger? Can I modify my script for the purpose?
Model: PB G4 1.0GHz FW 800 / PMG5 dual 1.8GHz
Browser: Safari 417.8
Operating System: Mac OS X (10.4)
Thank you Bonedoc, but I cannot find any solution in Jacques reply. His action script looks almost same as mine.
Do you have any idea why my script works in Panther and doesn’t in Tiger?
Thank you CAS. I tried your suggestion, but the result is same as before. Nothing happens at an arrival of rule-matched mail. On the next launch, a window of editing reply mail appears. Is this situation special for me only?
Rats. Well, I am thinking that the problem is that the Mail rule is generating the reply message, then the applescript is called, and the reply is already sent and done with. Therefore, when the script is asked to save a reply, it has no reply to save, since the script did not generate the reply in the first place.
The simplest solution that I can see is to go into the preferences for the account(s) that generate(s) the replies and make sure that they are not being deleted. Then, set up a Smart Mailbox to hold them for review whenever the user gets home from whatever trip they are going on.
The other solution is to use a Mail rule simply to call a script that generates a reply and then that reply can be saved where ever the use desires.
Well, I can’t get it to work. Here is what I have so far:
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
repeat with eachMessage in theMessages
set re_ply to reply eachMessage with reply to all and opening window
set re_ply's content to ("The reply" & return & return)
send re_ply
save re_ply
end repeat
end tell
end perform mail action with messages
end using terms from
During my testing, I was able to get Mail to generate a reply automatically, but I could not get it to write any content into the message, or send it, or save it. I think the code above should be working, but I am not terribly experienced with scripting Mail in this way. Hopefully someone more experienced with Mail will stop by soon and help out. Of course, it may very well be that this part of scripting Mail is not fully functional, either.
I tested your script and got the same result. A reply window was opened but that’s all. No close, no save. This does not satisfy the original demandant;
The reply with certation and signature only is automatic saved in Draft mailbox.
He’ll fill out the actual reply for each mail in Draft mailbox, and send them.