I’ve just discovered something VERY interesting.
Creating a sub-mailbox ONLY works on pre-El Capitan created mailboxes, and then only at one nested level.
It looks to me as though El Capitan is doing something with it’s newly created mailboxes in regards to the titles, that prevents applescript runner from recognising the mailbox! Just a guess.
I’ll update my bug report. Report number is 23455313
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 -- 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)} # 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
#
# 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
On 9 Nov 2015, at 8:31 AM, Christopher Stone <
email@hidden> wrote:
On Nov 08, 2015, at 15:21, Brian Christmas <
email@hidden> wrote:
However, my code DOES run successfully under Yosemite, so I believe there’s just a problem with El Capitan.
______________________________________________________________________
Hey Brian,
Interesting.
That means Apple fixed it in Yosemite and broke it again in El Capitan, because it was broken sometime pre-Yosemite.