Here is my first attempt at an AppleScript program, which met with ignominious defeat:
tell application "Mail"
tell mailbox "INBOX"
count messages
end tell
end tell
It compiled, but when I ran it, I got the error message
error "Mail got an error: Can’t get mailbox \"INBOX\"." number -1728 from mailbox "INBOX"
Can someone tell me what is wrong, and if there is a short introduction to AppleScript, written for someone used to programming?
Best Answer
Your mistake is understandable in what you expect should be the syntax.
Each account has it's own mailbox named "INBOX"
In Mail the mailbox inbox is the reference to the top level inbox that shows contents of all other inboxes named "INBOX"
2 examples:
Example 1
Example 2
Both return and log the same total.
But example 1 also logs the individual count of each "INBOX"
A good place to start is to read through: AppleScript Fundamentals