• 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: Oldest Message in Mail's Trash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Oldest Message in Mail's Trash


  • Subject: Re: Oldest Message in Mail's Trash
  • From: Luther Fuller <email@hidden>
  • Date: Sun, 29 Jun 2008 12:45:52 -0500

I've been doing some experiments with Mail scripting to make sure I understood the problem and my solution.
Consider this script ...


tell application "Mail"
	activate
	if (count message viewers) = 0 then make new message viewer
	set frontViewer to (some message viewer whose index is 1)
	try
		set selected messages of frontViewer to {message -1 of frontViewer}
	end try
end tell

I thought this would select the last message in the message viewer, perhaps relative to the sort column that was selected. Turns out the sort order has nothing to do with what is selected.

The line 'message -1 of frontViewer', when used with Inbox, Sent, Trash and Junk ALWAYS refers to the OLDEST message in SOME account of that mailbox. (I think this may explain why I was not getting the oldest message in my original post.) If you choose an account of one of these mailboxes, you do get the oldest message. And you can write something like ...

set selected messages of frontViewer to {message -1 thru -n of frontViewer}

to select a range of oldest messages. So, what does the dictionary have to say about this? I looked and found that using indexes this way isn't documented. And, I also noticed that the dictionary contains the phrase 'visible messages'. Leading to this script ...

tell application "Mail"
activate
if (count message viewers) = 0 then make new message viewer
set frontViewer to (some message viewer whose index is 1)
try
set msgList to (visible messages of frontViewer)
set selected messages of frontViewer to (items -1 thru -4 of msgList) as list
end try
end tell


This works correctly, but notice that I again have the problem I was trying to avoid. 'visible messages' cannot use indexing (I tried), so, the list 'msgList' may be huge.

_______________________________________________
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
References: 
 >Oldest Message in Mail's Trash (From: Luther Fuller <email@hidden>)
 >Re: Oldest Message in Mail's Trash (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: set "busy status" ?
  • Next by Date: smb share naming
  • Previous by thread: Re: Oldest Message in Mail's Trash
  • Next by thread: Re: Oldest Message in Mail's Trash
  • Index(es):
    • Date
    • Thread