MACSCRPT Archives

July 2009

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
John Delacour <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 29 Jul 2009 10:17:42 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (32 lines)
At 11:32 +0900 29/7/09, Nobumi Iyanaga wrote:

>...I need to limit the range of messages to be processed from "the 
>currently selected" message, to the last message, sorted by date 
>received...

Hello Nobumi,

I don't use Mail and have no duplicates in my Inboxes to test a 
script with, but  it seems messages are given an id in order of 
arrival, so you can get a list of the message ids (not to be confused 
with the their ids) of the messages that arrived since the selected 
message:

tell application "Mail"
   set _selected to first item in (get selection)
   set _id to id of _selected
   set _mailbox to mailbox of _selected
   set _range to the messages in _mailbox whose id is greater than (_id - 1)
   set _messageids to {}
   repeat with _i in _range
     set end of _messageids to message id of _i
   end repeat
   _messageids
end tell

and then loop again through _range, adding the message id to to a new 
list as you go and deleting messages whose id is already in the new 
list.

JD

ATOM RSS1 RSS2