Here are screen shots of my Apple Mail Settings/Rules and the contents of the first rule in the list. I would expect this to execute whenever I get a new email but it is not doing so – in fact it never executes.
It looks like Mail should be applying the rule because it’s at the top of the list and marked as Active. I recommend making sure that the rule works manually before investigating why it isn’t working automatically. Have you tested that the rule works by selecting a message and choosing Message ‣ Apply Rules? You have it configured to play the Funky sound, so this should make the sound play, and if you hear the sound that will show that the rule was applied.
Message/Apply Rules worked. Now WTF? I’ve been working with computers since the ‘70s and in some circles am considered an expert, but they always find a new way to frustrate me.
I’m afraid that sounds like a Mail bug, and I’m not sure what you could do about it directly. One option would be to save the script as a standalone app, and then it could run in the background and periodically check for new messages instead of relying on Mail to be the trigger.
I tried that too and couldn’t make it work. I think it’s something I’m doing wrong. The internet is amazingly vague about standalone stay-open recurring Applescript apps. Your app seems to have an idle handler, so it should work.
When you use Script Editor to save the script in Application format, make sure that Stay open after run handler is checked before you click the Save button.
I finally got the stand-alone script working. I had a flash and tried giving it full disk access permission in Settings/Privacy and Security and that worked and it now repeats on its own (though it works without the permission once if you run it manually).