• 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: scripting mail to select mailboxes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scripting mail to select mailboxes


  • Subject: Re: scripting mail to select mailboxes
  • From: cricket <email@hidden>
  • Date: Thu, 13 Mar 2003 11:00:34 -0800

In your first posting, you had this line:

tell app "Mail"
set selected mailboxes of message viewer 1 to {drafts mailbox, sent mailbox, mailbox "Stuff" of account "email@hidden"}
end tell

This is functionally equivalent to this code:

tell app "Mail"
tell message viewer 1
set selected mailboxes to {drafts mailbox, sent mailbox, mailbox "Stuff" of account "email@hidden"}
end tell
end tell

The problem here is that 'drafts mailbox' and 'sent mailbox' are part of the message viewer class, but mailbox is part of the account class (for mailboxes that belong to an account) or the application class (for mailboxes that don't belong to an account -- i.e. On My Mac).

You need to ask for the mailbox within either an application tell block or an account tell block. Inside a message viewer tell block won't work.

- cricket

On Wednesday, March 12, 2003, at 7:50 PM, David P. Baker wrote:

Sorry, I don't understand. I'm not inside a "tell message viewer" block. I'm inside a "tell application 'Mail'" block. Here's a test script, showing output. How should I be doing this? Note that this works IF the new mailbox is a "standard" mailbox (in, out, drafts, sent, or trash).

tell application "Mail" to get selected mailboxes of message viewer 1
-- {mailbox "Loft" of account "email@hidden" of application "Mail"}

tell application "Mail"
set theBox to mailbox "Stuff" of account "email@hidden"
set selBoxes to {theBox}
set selected mailboxes of message viewer 1 to selBoxes
get selected mailboxes of message viewer 1
end tell
-- {mailbox "Loft" of account "email@hidden" of application "Mail"}


On Wednesday, March 12, 2003, at 05:18 PM, cricket wrote:


On Wednesday, March 12, 2003, at 1:20 PM, David P. Baker wrote:

set selected mailboxes of message viewer 1 to {trash mailbox, in mailbox}
get selected mailboxes of message viewer 1
-- {in mailbox, trash mailbox}

set selected mailboxes of message viewer 1 to {drafts mailbox, sent mailbox, mailbox "Stuff" of account "email@hidden"}
get selected mailboxes of message viewer 1
-- {in mailbox, trash mailbox}

The mailbox class is part of the account class, so it won't work if nested in a 'tell message viewer' block. So, try this:

set theMailbox to mailbox "Stuff" of account "email@hidden"
tell message viewer 1
set selected mailboxes to {drafts mailbox, sent mailbox, }
get selected mailboxes
end tell

Applescript is strict about containment hierarchy.

- cricket

----->
Software Entomologist  Mail for Mac OS X
http://www.apple.com/macosx/jaguar/mail.html
---------->
See? We even have to whisper. It's a whole new world.



----->
Software Entomologist  Mail for Mac OS X
http://www.apple.com/macosx/jaguar/mail.html
---------->
In theory, there is no difference between theory and practice. In practice, however, there is.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: scripting mail to select mailboxes
      • From: "David P. Baker" <email@hidden>
References: 
 >Re: scripting mail to select mailboxes (From: "David P. Baker" <email@hidden>)

  • Prev by Date: Re: Can I script Safari?
  • Next by Date: Re: Date anomaly
  • Previous by thread: Re: scripting mail to select mailboxes
  • Next by thread: Re: scripting mail to select mailboxes
  • Index(es):
    • Date
    • Thread