Rép: New to applescript: year of
Rép: New to applescript: year of
- Subject: Rép: New to applescript: year of
- From: Yvan KOENIG <email@hidden>
- Date: Thu, 28 Sep 2006 14:55:24 +0200
Le 28 sept. 2006 à 14:39, Philip Aker a écrit :
On 2006-09-28, at 03:53:28, Yvan KOENIG wrote:
Either it's working or it ain't. If it's not working I can post
an example script which works OMM (OS X 10.4.7/Mail 2.1).
The two versions passed in this message:
De : email@hidden
Objet : Rép : New to applescript: year of
Date : 27 septembre 2006 19:11:52 HAEC
À : email@hidden
works flawlessly but of course I am interested to "read" an other
soluce.
I no longer have those messages but the problem I referred to was
the loop:
repeat with myMessage in (every message of mailbox laSource)
When you have a situation when one of the items is moved out of the
container,
... then move myMessage to mailbox laDestination
then the container is altered -- it no longer contains the number
of items it thought it had when it started -- and the container
count is compromised. This is clearly shown in the error:
get item 4 of every message of mailbox "zzz"
"Erreur dans Mail : NSReceiverEvaluationScriptError: 4"
whereas the previous enumerated items passed successfully.
Hamish Sanderson has made an excellent post to illustrate:
tell application "Mail"
move (every message of mailbox laSource whose date received ≥
startDate and date received < endDate) to mailbox laDestination
end tell
Here, he bypasses a loop construct entirely and deals directly with
the result list of the query.
The intent of my post was to show that if you are going to use a
loop (which may be necessary if the search criteria is
complicated), then only load the input list in the loop -- don't
delete or move there:
tell application "Mail"
set mlist to {}
tell mailbox sbox
set mcount to count of messages
repeat with m from 1 to mcount
if (somecriteria is true) then
set end of mlist to message m
end if
end repeat
end tell
move mlist to mailbox dbox
end tell
Philip Aker
Thanks
So, If I understand well,
-- version 1
set {laSource, laDestination} to {"zzz", "xyz"}
tell application "Mail"
set k to count of messages of mailbox laSource
if k > 0 then
repeat with myMessage in (get every message of mailbox laSource)
if year of (get date received of myMessage) = 2005 then move
myMessage to mailbox laDestination
end repeat
end if
end tell
builds a huge list of every messages and works because it doesn't
work on the mbox internals.
tell application "Mail"
set mlist to {}
tell mailbox sbox
set mcount to count of messages
repeat with m from 1 to mcount
if (somecriteria is true) then
set end of mlist to message m
end if
end repeat
end tell
move mlist to mailbox dbox
end tell
doesn't work on the mbox internals but build a smaller list (and
moves all the items in a single operation).
I was reluctant to try to use whose because last week, I met some
serious problems with it … but it's an other story ;-)
Yvan KOENIG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden