Hi all,
Could someone see if this handler crashes Mail.app on your system?
To test, send yourself an email with a completely blank contents. Then make a mail rule for “every message” that calls this script. Then select the blank message in the Inbox and choose Apply Rules from the Message menu.
set LF to ASCII character 10
using terms from application "Mail"
on perform mail action with messages theMessages
display dialog "Executed Zap"
repeat with theMessage in theMessages
if (content of theMessage is LF) or (content of theMessage is missing value) or (content of theMessage is "") then
display dialog "Matched " & (content of the message)
delete the message
end if
end repeat
end perform mail action with messages
end using terms from
It displays the first display dialog (“Executed Zap”), then crashes Mail.app.
I hate to have to go to a cron-job type thing to trash these blank messages every 24 hours or so, but calling a script from a Mail rule seems to have problems.
I would appreciate any help on this, as I am sure that I may have a bad construct somewhere. Many thanks!!
worked fine on an incomming message but it doesn’t work if you click apply rules
Thanks Kim.
So it didn’t crash Mail.app?
Did it display both dialogs and then delete the message, placing it in the Trash mailbox?
There must be something wrong with my Mail.app - it is crashing in CoreGraphics whenever that script is executed.
doesn’t work == crashed?
doesn’t work == no effect?
doesn’t work == error during execution?
doesn’t work == unintended or unexpected outcome?
Thanks Jacques.
I removed the display dialog and it no longer crashes Mail.app, but it does not delete the message either, so I need to trace the execution of the handler.
A stand-alone script, NOT called from a Mail Rule, works well:
tell application "Mail"
set oneWeekAgo to ((current date) - 7 * days)
set LF to ASCII character 10
set theMessages to (messages of inbox) whose date received is greater than oneWeekAgo
repeat with theMessage in theMessages
if content of theMessage is LF then
delete theMessage
end if
end repeat
end tell
Do you know of a way to debug an “on perform mail action” handler that is called by a Rule? I have an email in to Late Night Software about this - I thought there was a way to trigger the handler for debugging, but coding “perform mail action” as a statement does not call into the “on perform Mail action” handler.
Thanks a lot!!
Now I can get to debugging.
Johnny