Hmm, more Mail mysteries. Wonder if anyone can throw some light on this.
I’ve got a mail rule that calls a numbers spreadsheet and updates it with info from the incoming message. Works just fine. Except…I also want the message to be marked as unread after the spreadsheet has been successfully updated.
I’ve tried two approaches:
1. In the rule, add the condition ‘mark as read’.
Problem: even though I add this condition after the ‘Run AppleScript’ action, it always moves to before it. The result of this is the message gets marked as unread, but my script doesn’t get called any my numbers sheet doesn’t update.
So instead, I tried
2. In the applescript, add the line
set read status of theMessages to true
just before the end of the "perform action…" handler.
Problem: now the numbers sheet updates, but the message remains as unread.
Any ideas how do I get *both* of these to work together? Where can I put the ‘set read status..' line to make it work?
The whole mail handler looks like this (with some creative substitutions for public posting):
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
--get customer name from msg content
set this_item to item 1 of theMessages
set theTxt to this_item's content
…
my letsDoNumbers(theSource, theCustard, theEmail)
— everything works OK up to this point, however...
—this doesn’t work:
set read status of theMessages to true
end if
end tell
—putting it here instead doesn’t work either:
#set read status of theMessages to true
end perform mail action with messages
end using terms from