I am successfully using the script below to mark all messages read in a faster manner than checking the status of every individual message. I cannot figure out the syntax to select ALL mailboxes vs. having to manually select mailboxes. When I changed ‘selected mailboxes’ to ‘every mailbox’, I get an error: “Can’t get every mailbox of message viewer 1.”
Does anyone have an idea on how to have this script look at every mailbox instead of having to manually select them?
Thanks!
set processSubMailboxes to true
tell application "Mail"
tell front message viewer
set theSelectedMailboxes to selected mailboxes
repeat with a from 1 to length of theSelectedMailboxes
set theCurrentMailbox to item a of theSelectedMailboxes
processMailbox(theCurrentMailbox, processSubMailboxes) of me
end repeat
end tell
end tell
on processMailbox(theMailbox, processSubMailboxes)
tell application "Mail"
if processSubMailboxes = true then
set theSubMailboxes to every mailbox of theMailbox
repeat with a from 1 to length of theSubMailboxes
set theCurrentSubMailbox to item a of theSubMailboxes
processMailbox(theCurrentSubMailbox, processSubMailboxes) of me
end repeat
end if
tell application "Mail" to activate
tell application "Keyboard Maestro Engine"
do script "Mark All Mail Read"
end tell
set theSelection to selection
set theMessage to item 1 of theSelection
if read status of theMessage is false then
tell application "Mail" to activate
tell application "Keyboard Maestro Engine"
do script "Mark All Mail Read"
end tell
end if
end tell
end processMailbox