It would seem that Mail rules which execute AppleScripts are still very unreliable.
-------------------------------------------------------------------------------------------
using terms from application "Mail"
on perform mail action with messages messageList for rule theRule
try
tell application "Mail"
repeat with theMessage in messageList
set msgSubject to theMessage's subject
display notification "Mail Message" with title msgSubject subtitle ("Rule: " & name of theRule as Unicode text) sound name "Sosumi"
end repeat
end tell
on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
errorMessage() of me
end if
end try
end perform mail action with messages
end using terms from
on errorMessage()
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end errorMessage
-------------------------------------------------------------------------------------------
But it fails most of the time when rules are applied as message arrive.
Very disappointing.