set tempYearString to "2017"
property theMonth : "09"
property dailyName : "02"
tell application "Mail"
activate
######################################################
# Make Yearly mailbox
######################################################
# This works
if not (exists mailbox tempYearString) then
make new mailbox with properties {name:tempYearString & "/"}
repeat until exists mailbox tempYearString
do shell script ("sleep 0.1")
end repeat
end if
######################################################
# Make Monthly mailbox
######################################################
set loopCounter to 0
if not (exists mailbox (my theMonth) of mailbox tempYearString) then
try
make new mailbox with properties {name:(tempYearString & "/" & (my theMonth) & "/")}
on error errmsg
tell application "System Events" to display dialog "1 " & errmsg
end try
end if
set loopCounter to loopCounter + 1
do shell script ("sleep 0.1")
######################################################
# Make Daily mailbox
######################################################
if not (exists mailbox (my dailyName) of mailbox (my theMonth) of mailbox tempYearString) then
try
make new mailbox with properties {name:(tempYearString & "/" & my theMonth & "/" & my dailyName)}
on error errmsg
tell application "System Events" to display dialog "2 " & errmsg
end try
end if
end tell
say "Now running without added slashes"
set tempYearString to "2018"
tell application "Mail"
activate
######################################################
# Make Yearly mailbox
######################################################
# This works
if not (exists mailbox tempYearString) then
make new mailbox with properties {name:tempYearString}
repeat until exists mailbox tempYearString
do shell script ("sleep 0.1")
end repeat
end if
######################################################
# Make Monthly mailbox
######################################################
set loopCounter to 0
if not (exists mailbox (my theMonth) of mailbox tempYearString) then
try
make new mailbox with properties {name:(tempYearString & "/" & (my theMonth))}
on error errmsg
tell application "System Events" to display dialog "3 " & errmsg
end try
end if
set loopCounter to loopCounter + 1
do shell script ("sleep 0.1")
######################################################
# Make Daily mailbox
######################################################
if not (exists mailbox (my dailyName) of mailbox (my theMonth) of mailbox tempYearString) then
# activate
try
make new mailbox with properties {name:(tempYearString & "/" & my theMonth & "/" & my dailyName)}
on error errmsg
tell application "System Events" to display dialog "4 " & errmsg
end try
end if
end tell