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:
Deivy Petrescu <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 29 Jul 2009 09:50:10 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (152 lines)
On Jul 28, 2009, at 10:32 PM, Nobumi Iyanaga wrote:

> Hello Deivy,
>
> On Jul 29, 2009, at 10:20 AM, Deivy Petrescu wrote:
>
>> On Jul 28, 2009, at 8:28 PM, Nobumi Iyanaga wrote:
>>
>>> This seems to work fine in Mail too. But... I tried:
>>>
>>> tell application "Mail"
>>> 	set theLast to (count of messages of mailbox "INBOX" of account  
>>> "myaccount")
>>> end tell
>>>
>>> and I got a number. But when I do:
>>>
>>> tell application "Mail"
>>> 	set theLast to (count of messages of mailbox "INBOX" of account  
>>> "myaccount")
>>> 	get the content of (message theLast of mailbox "INBOX" of account  
>>> "myaccount")
>>> end tell
>>>
>>> I get a text which has no relation with the last message of my  
>>> 'mailbox "INBOX" of account "myaccount"'...
>>>
>>> This seems to mean that the reference by number to a specific  
>>> message does not work...??
>>>
>>> -------
>>>
>>> On Jul 29, 2009, at 12:37 AM, Deivy Petrescu wrote:
>>>
>>>> I use this script for myself.
>>>> It is a bit rough but does it job.
>>>>
>>>> -- paramenters
>>>> set mb to "INBOX"
>>>> set acct to "myaccount"
>>>> 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 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
>>>
>>> This seems very good, but because of the problem of the reference  
>>> by number, that I mentioned above, I cannot use this method...??
>>>
>>> Any other ideas?
>>>
>>> Thank you very much in advance!!
>>>
>>> Best regard,
>>>
>>> Nobumi Iyanaga
>>> Tokyo,
>>> Japan
>>
>>
>>
>> Nobumi,
>>
>> Last and first are properties which are set by the time the message  
>> is received.
>> Check, in your example above if  the last message is not the one  
>> that was the last by sorting via date received.
>
> In my example above, I used the number of messages in the INBOX  
> ("count of messages of mailbox "INBOX" of account "myaccount""); I  
> tried with the "last" property:
>
> tell application "Mail"
> 	get content of (last message of mailbox "INBOX" of account  
> "Nifty_mail")
> end tell
>
> I got the same result as the previous example. It is NOT the "last"  
> by date received...??
>
>>
>> And another point, you can use my script with no fear it only  
>> deletes messages if the ids are the same.
>
> This is very good to know. Thank you!
>
> But I need to limit the range of messages to be processed from "the  
> currently selected" message, to the last message, sorted by date  
> received...
>
> Best regard,
>
> Nobumi Iyanaga
> Tokyo,
> Japan



Nobumi,
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...


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






Deivy Petrescu
[log in to unmask]

ATOM RSS1 RSS2