• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: applescripting sub mailboxes in Mail
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: applescripting sub mailboxes in Mail


  • Subject: Re: applescripting sub mailboxes in Mail
  • From: Brian Christmas <email@hidden>
  • Date: Mon, 09 Nov 2015 08:51:26 +1100

G’day all

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.

--
Take Care,
Chris





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: applescripting sub mailboxes in Mail
      • From: Brian Christmas <email@hidden>
    • Re: applescripting sub mailboxes in Mail
      • From: Ray Robertson <email@hidden>
References: 
 >Fwd: applescripting sub mailboxes in Mail (From: Brian Christmas <email@hidden>)
 >Re: applescripting sub mailboxes in Mail (From: Christopher Stone <email@hidden>)
 >Re: applescripting sub mailboxes in Mail (From: Christopher Stone <email@hidden>)
 >Re: applescripting sub mailboxes in Mail (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: applescripting sub mailboxes in Mail
  • Next by Date: Re: Save as application - run only
  • Previous by thread: Re: applescripting sub mailboxes in Mail
  • Next by thread: Re: applescripting sub mailboxes in Mail
  • Index(es):
    • Date
    • Thread