• 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: Accessing/creating mailboxes in Mail.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing/creating mailboxes in Mail.app


  • Subject: Re: Accessing/creating mailboxes in Mail.app
  • From: Luther Fuller <email@hidden>
  • Date: Sun, 02 Jan 2011 08:34:32 -0600

On Jan 1, 2011, at 9:51 PM, Christopher Stone wrote:

Keep in mind that 'message viewer 1' does not refer the the front message viewer.  If you have more than one open you can get into trouble using that syntax.  (Mail continues to be an ugly beast to script.)

But ...

some message viewer whose index is 1

does seem to work correctly. I have a very large script that depends on this.
I have simplified the applicable part of my script to get this ...

on run
try
my main()
on error errText number errNr
if errNr = -128 then
return
else if errNr = -2700 then
tell application "Mail" to display dialog errText buttons {"OK"} default button 1
else
"Error = " & errNr & return & errText
display dialog the result buttons {"OK"} default button 1
end if
end try
end run -------------------------------------------------------

on main()
tell application "System Events" to ((name of every process) contains "Mail")
if not the result then
beep
return
end if


tell application "Mail"
activate
try
set frontViewer to (some message viewer whose index is 1)
on error
error "A message viewer window must be open and frontmost in Mail."
end try
set mailBoxList to (selected mailboxes of frontViewer)
display dialog (name of (item 1 of mailBoxList)) as text buttons {"OK"} default button 1
end tell
end main -------------------------------------------------------

I have tried running it with various and multiple windows open in Mail and it behaves correctly every time.
I can't break it. Can you?

 _______________________________________________
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: Accessing/creating mailboxes in Mail.app
      • From: Christopher Stone <email@hidden>
    • Re: Accessing/creating mailboxes in Mail.app
      • From: Axel Luttgens <email@hidden>
References: 
 >Re: Accessing/creating mailboxes in Mail.app (From: Luther Fuller <email@hidden>)
 >Re: Accessing/creating mailboxes in Mail.app (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: How to do a goto with Applescript?
  • Next by Date: Re: How to do a goto with Applescript?
  • Previous by thread: Re: Accessing/creating mailboxes in Mail.app
  • Next by thread: Re: Accessing/creating mailboxes in Mail.app
  • Index(es):
    • Date
    • Thread