Mail.App and sub-MailBoxes

Working through an AppleScript to scan MailBoxes in Mail.

The mailboxes are organized as subfolder

Customers
CustomerA
CustomerB
…

repeat with theMailbox in every mailbox
set currentMailbox to theMailbox
set mailboxName to the name of currentMailbox
try
set messages_list to every message of mailbox mailboxName

results in

"–> error number -1728 from mailbox “CustomerA”

It works for mailboxes that are not subfolders, so I assume that the fact that the mailbox is a subordinate requires another way to refer to it.

an help would be appreciated.

The container of mailbox mailboxName has to be specified.

Will try to debug, but a blind replace failed

Original Code resulted with non-sub-mailboxed

And for sub-mailboxed

New Code results in for all mailboxes

Here is the full code;

Hi,

two notes:

¢ all mailboxes in subfolders are also listed in mailboxes of application “Mail”
¢ the reference to a sub mailbox is mailbox “Customers/CustomerA”

got it;

set messages_list to every message of mailbox mailboxName

changed to

set messages_list to every message of theMailbox

fixed