Q: Mail Applescript "set new mail sound" -> Apple Event handler failed
The following Applescript segment works in Snow Leopard and fails in Lion with "AppleEvent handler failed. number -10000"
tell application "Mail"
set new mail sound to "Glass"
end tell
In addition, the Apple-supplied, Mail Applescript for gathering Mail information "Display All Accounts and Preferences.scpt" fails
(again with "AppleEvent handler failed. number -10000") on the line
set displayString to displayString & my formatFields("New mail sound", new mail sound) & return
The Console Log reports the following error.
Mail: [<MailApp 0x7fd6a9e009a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key newMailSound.
The Mail Applescript property "new mail sound" appears not to be recognized correctly.
I do not have any Mail plugins. Several additional sounds have been added to the system sound set. Mail reports no problems using them.
Under Snow Leopard, I used the same Applescripts (fired off by iCal) which turned on/off Mail's New Mail Sound depending on the time of day, i.e. I set the new mail sound to be "Silent Alert" in the evening and restored it to my default new mail alert in the morning. Any guidance as to what might be wrong and how to solve this problem would be very welcome.
iMac, Mac OS X (10.7.3)
Posted on Apr 16, 2012 1:36 PM
The following script might act as a workaround:
tell application "Mail" to activate
tell application "System Events" to tell process "Mail"
keystroke "," using {command down} -- open Mail preferences
click button 1 of tool bar 1 of window 1 -- General
click pop up button 5 of group 1 of group 1 of window 1
keystroke "Glass" & return
keystroke "w" using {command down} -- close Mail preferences
end tell
Since the above script uses GUI Scripting, you must enable the Accessibility Frameworks by clicking the checkbox labeled "Enable access for assistive devices" in the Universal Access System Preference pane.
Posted on Apr 16, 2012 2:46 PM