I’ve got a Smart Mailbox in Mail which contains only those messages which have been marked as flagged, and I’m trying to set a variable to represent all of the messages in that mailbox. It seems however that AppleScript doesn’t recognize Smart Mailboxes as equal to regular mailboxes.
For example, the following script works just fine if the mailbox named “Flagged Messages” is a normal mailbox, but if it is a Smart Mailbox, I get the error: “Mail got an error: NSReceiverEvaluationScriptError: 4”
tell application "Mail"
set theMessages to every message of mailbox "Flagged Messages"
end tell
Can anyone suggest a solution or workaround to this problem?
Right!
Smart mailboxes are just virtual mailboxes which contain search results from certain search criteria.
But unfortunately Apple is not consistent. You can’t access smart folders in Finder as well,
but smart playlists in iTunes and smart albums in iPhoto are accessible