This may be a bug but when I run the following script:
tell application "Mail"
set FirstAccount to first account
tell FirstAccount
set EveryMessage to every message in mailbox "INBOX"
end tell
end tell
It will list every message in my inbox (23 emails for example). Then if I then go and manually move all those messages into a folder and run the script again, it still says there are 23 messages in my inbox. But my inbox is actually empty.
Then if I restart Mail and run the script again, it comes back with the correct number - zero messages in the inbox.
Maybe there’s a cache that’s not getting cleared or something. Any ideas?