I need to find a way of checking whether a particular mailbox in Mail is selected or not.
I’ve managed to get the selected boxes, but it’s not a list, nor can it be changed to a list.
My script so far …
set myMailbox to "* items to shift"
tell application "Mail"
activate
set EveryMailboxList to mailboxes
set SelectedBoxes to (selected mailboxes of message viewers)
repeat with y in SelectedBoxes
beep
display dialog number of items of SelectedBoxes -- This is only seen as one item
if myMailbox is in y then
beep
end if
end repeat
end tell
Model: intel iMac
Browser: Safari 525.18
Operating System: Mac OS X (10.5)
set SelectedBoxes to (selected mailboxes of message viewers)
results a list in a list, because you are referecing all message viewers
so you need a second repeat loop to parse the items of each message viewer.
And I recommend to compare explicitly the name of the mailbox,
Edit: something like this
set myMailbox to "* items to shift"
tell application "Mail"
-- activate -- actually not needed
set EveryMailboxList to mailboxes
set SelectedBoxes to {}
repeat with i in (get selected mailboxes of message viewers)
repeat with j in contents of i
set end of SelectedBoxes to (get name of j)
end repeat
end repeat
beep
display dialog (count SelectedBoxes) -- This is only seen as one item
if myMailbox is in SelectedBoxes then
beep
end if
end tell