问题
When I access the satimage.osax scripting addition (which I'm using for its regex capability) from a Mail rule on Snow Leopard, I get errors, but it runs fine in Script Editor. The code below illustrates the problem. The first line executes fine, but the line inside the tell
block throws an error (below), from the mail rule version, which I had catching the error.
set substr to find text "a" in "abcd"
tell application "Mail"
set substr to find text "a" in "abcd"
end tell
So I tried a workaround: tell application "Finder" to ...
from within the Mail Rule script, but that then threw a security error.
回答1:
It's not a sandboxing problem - it's a 32/64 bit problem. Mail is a 64-bit application in Snow Leopard, and as of right now, Satimage.osax is a 32-bit addition. So for the time being, I set Mail to Open in 32-bit mode (see picture). I arrived at this conclusion after reading a MacScripter forum post. I'd still love to hear another workaround, in case Satimage stays a 32-bit addition.
回答2:
Given this is more than likely a sandboxing issue the only workaround I can think of is to place the calculations in a script or script application(1) outside of Mail (2), call that from Mail, and handle a returned result.
(1) Whichever works best for this situation.
(2) Your User Scripts folder would be a good place for this
来源:https://stackoverflow.com/questions/4102986/why-wont-this-scripting-addition-run-from-a-mail-rule