set AllMyBoxes to {}
tell application "Mail"
set myAccts to every account
repeat with anAcct in myAccts
set AllBoxes to every mailbox of anAcct
repeat with aBox in AllBoxes
set the end of AllMyBoxes to the contents of aBox
end repeat
end repeat
set MainBoxes to (mailboxes as list)
repeat with aBox in MainBoxes
set the end of AllMyBoxes to the contents of aBox
end repeat
end tell
AllMyBoxes
The last line lists what seems to be all my mailboxes, even -- amazingly! -- those that are inside other mailboxes, e.g.:
mailbox "Receipts/PayPal" of application "Mail"
mailbox "Receipts/Quicken" of application "Mail"
mailbox "Receipts/Received Stuff" of application "Mail"
mailbox "Receipts" of application "Mail"
This is a different result from Michelle's suggestion (above) that overlooked messages in subfolders.
Evidently, some mailboxes belong to an account, e.g.:
mailbox "INBOX" of account "Dominant" of application "Mail"
mailbox "Drafts" of account "Dominant" of application "Mail"
mailbox "Sent Messages" of account "Dominant" of application "Mail"
mailbox "Deleted Messages" of account "Dominant" of application "Mail"
mailbox "INBOX" of account "Enkidu" of application "Mail"
mailbox "Drafts" of account "Enkidu" of application "Mail"
mailbox "Deleted Messages" of account "Enkidu" of application "Mail"
These are not included in "mailboxes". I.e., "set MainBoxes to (mailboxes as list)" does not retrieve any of these. That's why the code above has to fetch these separately.
Some mailboxes are missing (e.g., "Sent Messages" of account "Enkidu"), I hope because they are empty.
I think from this point I'll be able to code up something to visit every message with great confidence.
Thanks for y'all's help!
--Gil
Confidential to Yvan: "Y'all's" is Southern slang, the plural possessive form for "you." If I said, "Thanks for your help!", it would be ambiguous whether I meant one person or several. Southern solves that problem with "you-all" and its declensions and contractions. You-plural-possessive is probably simpler in French, but we-uns has to work with what we got.