Hello everyone!
I’ve written an AppleScript that creates a new Mail rule and attempts to tell that Mail rule to run an AppleScript.
tell application "Finder"
set theScriptPath to (home as string) & "Library:Application Scripts:com.apple.mail:My script.scpt"
end tell
tell application "Mail"
set theNewRule to make new rule at end of rules with properties {name:"Test rule"}
tell theNewRule
make new rule condition at end of rule conditions with properties {rule type:matches every message}
set run script to theScriptPath
set enabled to true
end tell
set scriptPathTest to ""
try
set scriptPathTest to run script of first rule whose name is "Test rule"
end try
end tell
The rule is successfully created, but in Mail on OS X 10.8.2 the ‘Run AppleScript’ set has ‘No script selected’ in its popup menu.
I added the scriptPathTest step at the end to try and work out what’s going behind the scenes. The real path to the script file is:
“Macintosh HD:Users:tom:Library:Application Scripts:com.apple.mail:My script.scpt”
However, here it returns:
“Macintosh HD:Users:tom:Library:Application Scripts:com.apple.mail:Users:tom:Library:Application Scripts:com.apple.mail:My script.scpt”
If I go into Mail and manually select the script, AppleScript returns the correct script path.
So. has anyone come across this before? Is it something that I’m doing wrong, or a bug in Mail when creating a rule that runs an AppleScript?