File not found with folderitem.child

My application archives emails on the Mac. I get the mailboxes from AppleMail with AppleScript. Each mailbox - except for Gmail - has a corresponding folderitem on the hard disk. The mailbox “@read” for the Macsend account has the folderitem

/Users/beatrixwillius\ 1/Library/Mail/V5/76311AE0-D7FB-4321-910E-3ECABA2B1FE6/@read.mbox

Because of the wonderful security the app needs full hard disk access.

For one user some but not all mailboxes are missing. I have traced this back to a folderitem.child call. The code first finds the path of the mailbox which is the part from “/Users” to “FE6”. Then it moves down level by level by doing folderitem.child (error handling omitted):

dim theResult as FolderItem = currentAccountDirectory
dim thePath(-1) as String = MailboxPath.Split(globals.MailboxDivider)
thePath.RemoveRowAt(0) 'don't need the account name itself

for currentPath as Integer = 0 to thePath.LastRowIndex
  dim ChildPath as String = thePath(currentPath) + ".mbox"
  theResult = theResult.Child(ChildPath)
next

I added some logging to the code and got the following back:

2020-12-08 11:58:19 emlxIterator.Constructor Mailboxes:::computer:::Hardware:::Canon:::Canon_8400F

2020-12-08 11:58:19 emlxIterator.Constructor current account directory: /Users/mark/Library/Mail/V6/87D8C005-8AF9-4467-B6E5-6D25C7056959

2020-12-08 11:58:19 emlxIterator.getMailboxFolderitem path: Computer

2020-12-08 11:58:19 emlxIterator.getMailboxFolderitem path folderitem: /Users/mark/Library/Mail/V6/87D8C005-8AF9-4467-B6E5-6D25C7056959/Computer.mbox

2020-12-08 11:58:19 emlxIterator.getMailboxFolderitem path: Hardware

2020-12-08 11:58:19 emlxIterator.getMailboxFolderitem path folderitem: /Users/mark/Library/Mail/V6/87D8C005-8AF9-4467-B6E5-6D25C7056959/Computer.mbox/Hardware.mbox

2020-12-08 11:58:19 emlxIterator.getMailboxFolderitem path: Canon

2020-12-08 11:58:19 emlxIterator.getMailboxFolderitem path: Canon_8400F

2020-12-08 11:58:19 emlxIterator.GetNumberOfObjects nothing there

Hardware exists. But the subfolder Canon does not. I had the user do a “ls -l” on the Hardware folder with the following result for c:

drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 CablesToGo.mbox
drwxr-xr-x@ 8 mark staff 256 Dec 4 14:05 Canon.mbox
drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 ClubMac.mbox
drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 Comply.mbox
drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 CompuCover.mbox
drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 Computers4Sure.mbox
drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 ContourDesign.mbox
drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 Corsair.mbox
drwxr-xr-x@ 4 mark staff 128 Nov 12 2019 Cowin.mbox
drwxr-xr-x@ 4 mark staff 128 Jan 31 2020 CyberPower.mbox

I also made a loop for the child items with FileListMBS. The result for the items with c is:

CablesNMor.mbox
CablesToGo.mbox
Canon Pixma MG6120.mbox
ClubMac.mbox
Comply.mbox
CompuCover.mbox
Computers4Sure.mbox
ContourDesign.mbox
Corsair.mbox
Cowin.mbox
CyberPower.mbox

Does anyone have an idea what might cause this odd behaviour? Xojo 2019r3, user has Mojave.

I can see that ls -l shows “Canon.mbox” while FileListMBS shows “Canon Pixma MG5120.mbox” are they not the same folder?

Good catch Wayne.

The folder is a package “.mbox” and as such can contain a info.plist file which can be used to give the folder different names. My guess is “ls -la” is giving the correct name, but probably the NSURL classes are using the display name. Let me think about this some.

I could read the plist. Alternatively, I could do the NSURL with a localized name according to https://www.monkeybreadsoftware.net/class-nsurlmbs.shtml .

But I still fail so see why a couple of regular mailboxes should have a special name.

I agree with you there.

I do recall when I investigated something similar earlier in the year, accessing the NSURL using the actual file name and not the display name worked.

There’s some weird stuff going on nowdays.