Need help on nested mail folders

Hello Here is my script and for some reason it does not work?

Can anyone point out my mistakes?



--This part is coming from cells in a Numbers document.
set grandParentMailbox to Client_Folder_name_clean
set parentMailbox to Client_foldernameDate
set childMailbox to file_name

tell application "Mail"
	if (mailbox (grandParentMailbox) exists) = false then
		make new mailbox with properties {name:grandParentMailbox}
		set frontViewer to (some message viewer whose index is 1)
		set selected mailboxes of frontViewer to {mailbox grandParentMailbox}
		my waitTillFileExists(grandParentMailbox) & ".mbox"
	end if
end tell

tell application "Mail"
	if (mailbox (grandParentMailbox / parentMailbox) exists) = false then
		make new mailbox with properties {name:grandParentMailbox / parentMailbox}
		set frontViewer to (some message viewer whose index is 1)
		set selected mailboxes of frontViewer to {(mailbox grandParentMailbox) / parentMailbox}
		my waitTillFileExists(grandParentMailbox / parentMailbox) & ".mbox"
	end if
end tell

tell application "Mail"
	if (mailbox (grandParentMailbox / parentMailbox / childMailbox) exists) = false then
		make new mailbox with properties {name:grandParentMailbox / parentMailbox / childMailbox}
		set frontViewer to (some message viewer whose index is 1)
		set selected mailboxes of frontViewer to {(mailbox grandParentMailbox) / parentMailbox / childMailbox}
		my waitTillFileExists(grandParentMailbox / parentMailbox / childMailbox) & ".mbox"
	end if
end tell

on waitTillFileExists(mBox)
	set parentDir to "/Users/clbair2012/Library/Mail/V2/Mailboxes"
	set theMailBoxFile to parentDir & "/" & mBox & "/Info.plist"
	repeat while (my FileExists(theMailBoxFile) = false)
		delay 4
	end repeat
end waitTillFileExists


Here is the error message that I get

error “Can’t make "SAS - Safetool sas" into type real.” number -1700 from “SAS - Safetool sas” to real


SAS - Safetool sas is the “grandParentMailbox” picked up from my Numbers document.

Kind regards

Hi,

you’re going to divide two strings, which does not work


.
mailbox (grandParentMailbox / parentMailbox)
.

you have to concatenate the strings


.
mailbox (grandParentMailbox & "/" & parentMailbox) 
.

Hello Stefan,

Thanks for your quick reply… I overlooked that concatenate…

However I still have some error messages as such I don’t know why.

tell application “Mail”
exists mailbox “CGM - Champagne G.H. Martel & Co”
→ true
exists mailbox “CGM - Champagne G.H. Martel & Co/CGM - 2014-2015”
→ false
make new mailbox with properties {name:“CGM - Champagne G.H. Martel & Co/CGM - 2014-2015”}
→ missing value
get some message viewer whose index = 1
→ message viewer id 1
get mailbox “CGM - Champagne G.H. Martel & Co”
→ mailbox “CGM - Champagne G.H. Martel & Co”
Result:
error “Can’t make «class mbxp» "CGM - Champagne G.H. Martel & Co" of application "Mail" into type list, record or text.” number -1700 from «class mbxp» “CGM - Champagne G.H. Martel & Co” to list, record or text