Mail and Applescript making new mailboxes under El Capitan failing
G'day
I'm trying to make nested Mail folders under El Capitan.
However, Applescript with Mail only allows ONE level of folder to be created. It refuses to make nested folders, UNLESS the parent folder is one created under Yosemite, and then Mail ONLY creates ONE level of nested folders.
I've lodged a bug report, and heard nothing so far.
Does anyone know of a workaround, please?
Regards
Santa
tell application "Mail"
activate
if not (exists mailbox "Bar") then make new mailbox with properties {name:("Bar" as rich text)} # Works
do shell script ("sleep 0.2")
set selected mailboxes of message viewer 1 to mailbox "Bar"
tell application "System Events" to tell process "Mail"
click menu bar item "Mailbox" of menu bar 1
do shell script ("sleep 0.1")
click menu item "Rebuild" of menu 1 of menu bar item "Mailbox" of menu bar 1
end tell
do shell script ("sleep 0.1") # Tried delays up to 4 seconds
quit
end tell
do shell script ("sleep 2") # Tried delays up to 4 seconds
tell application "Mail"
activate
#
# Try creating within pre-existing mailbox created with Yosemite ('Year 2015')-- WORKS at ONE level ONLY
#
if not (exists mailbox "Dandy" of mailbox "Year 2015") then
beep
set x to 0
repeat until exists mailbox "Dandy" of mailbox "Year 2015"
set x to x + 1
if x > 3 then exit repeat
try
make new mailbox with properties {name:("Year 2015/Dandy" as rich text)} #display dialog errmsg
end try
do shell script ("sleep 0.1")
end repeat
end if
#
# FAILS
#
if not (exists mailbox "Jim" of mailbox "Dandy" of mailbox "Year 2015") then
beep
try
make new mailbox with properties {name:"Year 2015/Dandy/Jim"}
on error errmsg
display dialog errmsg
end try
end if
end tell
tell application "Mail"
activate
if not (exists mailbox "Dandy" of mailbox "Bar") then
beep
set x to 0
repeat until exists mailbox "Dandy" of mailbox "Bar"
set x to x + 1
if x > 3 then exit repeat
try
make new mailbox with properties {name:("Bar/Dandy" as rich text)} # Errors with 'Mail got an error: AppleEvent handler failed.'
on error errmsg
#display dialog errmsg
end try
do shell script ("sleep 0.1")
end repeat
end if
do shell script ("sleep 0.2")
if not (exists mailbox "Jim" of mailbox "Dandy" of mailbox "Bar") then
beep
try
make new mailbox with properties {name:"Bar/Dandy/Jim"}
on error errmsg
display dialog errmsg
end try
end if
end tell
late 2014 27" i7 iMac-OTHER, OS X El Capitan (10.11.1), null