I recently wrote a few scripts that are triggered by rules in Mail; they're nothing fancy; they verbally announce the arrival of certain message types using the "Say" command.
Your script would probably work just fine if reduced to this:
tell application "Finder"
activate -- you want the Finder to come to the front to display the dialog rather than bounce in the dock
display dialog "This computer will go to sleep in 1 minute." buttons {"Sleep", "Cancel"} default button 2 giving up after 60
sleep
end tell
Save it as a script (not an application); save it someplace handy; then call it from a Mail rule.
In Mail, edit your rule. In the "Perform the following actions" section, select "Run AppleScript".
Click the "Choose..." button, and in the resulting dialog, select the script you saved earlier.
That should do it.
--
Bryan Vines
From: Brian Taylor <email@hidden>
Subject: Getting script to run with apple mail rules.
Does anybody know the trick to get a script to run with mail.app
rules. Here is the script I wan to run when a message meets a
certain filter.
using terms from application "Mail"
on perform mail action with messages theMessages for rule therule
tell application "Finder"
display dialog "This computer will go to sleep in 1 minute."
buttons {"Sleep", "Cancel"} default button 2 giving up after 60
sleep
end tell
end perform mail action with messages
end using terms from
I've tried everything I can think of. Seems like it should work.
Can't get it to run.
Thanks.
Thank You,
Brian Taylor