Hello John and Deivy, On Jul 29, 2009, at 10:50 PM, Deivy Petrescu wrote: > play with the script below, it should give you some ideas. > By the way, in all the Macs I've tested here last message returns > the last by the earliest date. > I've no idea what is the problem with your Mail... Yes, this is really strange, but in my two machine, running OS 10.4 and 10.5, I have the same result... > > > set mb to 1 > set acct to 1 > set First_Msg to 250 > set Last_Msg to 200 > > --script that in this case erase repeated messages in the range > 200 to 250 from the mailbox mb of account acct > > with timeout of 3900 seconds > tell application "Mail" > --tell mailbox mb of account acct to set al to every message > whose date received < (current date) > --return al > set alist to {} > set anumber to count messages in mailbox 1 of account 1 > tell mailbox 1 of account 1 to repeat with jj from 0 to 10 > set end of alist to ({sender, subject, date received} of message > (anumber - jj)) & ("Message number: " & (anumber - jj)) > end repeat > (* > repeat with msg from First_Msg to Last_Msg by -1 > if (message id of message msg) = (message id of message (msg - > 1)) then delete (message msg ) > end repeat > *) > end tell > end timeout > alist Thank you for this example. Combining your two scripts, I tested the following script: tell application "Mail" set _selected to first item in (get selection) set received to date received of _selected set _mailbox to mailbox of _selected set _range to messages in _mailbox whose date received ³ received set _messageids to {} repeat with _i in _range set end of _messageids to message id of _i set end of _messageids to {sender, subject, date received} of _i end repeat _messageids end tell This works very well. Now, I have to try to delete one of the messages of the same message id. As I cannot use the message number as in Deivy's example, I think I will have to do something like this: tell application "Mail" set _selected to first item in (get selection) set received to date received of _selected set _mailbox to mailbox of _selected set _range to messages in _mailbox whose date received ³ received --set _messageids to {} set last_id to "mydummy" repeat with _i in _range --set end of _messageids to message id of _i --set end of _messageids to {sender, subject, date received} of _i set this_id to message id of _i if this_id = last_id then delete message last_id end if set last_id to message id of _i end repeat -- _messageids end tell For now, I cannot test this script. Do you think this would work...? Thank you very much in advance. Best regard, Nobumi Iyanaga Tokyo, Japan