Mail rules that contain AppleScript pass the wrong message
When use AppleScript with Mail rules, Mail passes the wrong message to AppleScript.
If the AppleScript is in an Inbox rule, it runs on whatever email is highlighted in the inbox.
If the rule is triggered by a Mail Act-on keystroke, it run on an adjacent message to the one selected.
When triggered manually, the script works as expected, and on the selected message.
Same problem as here:
https://discussions.apple.com/thread/250106018
https://discussions.apple.com/thread/4820345
Happens with all scripts, but this one is short enough to embed here:
global FlName
tell application "Mail"
set theMsg to selection
open selection
set Dialogresult to the button returned of ("Process this email and Print as PDF" buttons
{"Yes", "No"} default button "Yes")
if Dialogresult is "Yes" then
...
Screenshots of rules:
MacBook Pro 13", macOS 10.13