I'm trying to build an AppleScript against Apple Mail to create a mail subfolder under another parent folder. The mail server is Microsoft exchange. While the script runs successfully, it creates the subfolder named as "ParentFolder/ChildFolder" under ParentFolder.
The script is simple:
on run argv
if (count of argv) is not 2 then
error "Usage: osascript create_mail_subfolder.applescript <parent-folder-name> <subfolder-name>"
end if
set parentFolderName to item 1 of argv
set subfolderName to item 2 of argv
tell application "Mail"
tell account "Exchange"
set NewMailbox to make new mailbox with properties {name:parentFolderName & "/" & subfolderName}
end tell
end tell
end run
The script runs but I get a folder called "Customers/testfolder" under "Customers":
% osascript testcreate.applescript "Customers" "testfolder"
I have confirmed that the subfolder I want to create doesn't already exist. The "Customers" folder does exist, but "testfolder" does not.
I have even tried renaming the "Customers/testfolder" folder to just "testfolder" but get a -10006 error, which suggests the name of the folder is read-only.
% osascript testcreate.applescript "Customers" "testfolder"
Customers/testfolder
testcreate.applescript:671:705: execution error: Can’t set name of "Customers/Customers/testfolder" to "Customers/testfolder". (-10006)
I see from this old MacRumors post that I'm not alone. Could anyone share a workaround for this issue or is there another way to create subfolders against Apple Mail?