Re: New to applescript: year of
Re: New to applescript: year of
- Subject: Re: New to applescript: year of
- From: Francis Derive <email@hidden>
- Date: Wed, 27 Sep 2006 18:26:16 +0200
On Sep 27, 2006, at 3:23 PM, Yvan KOENIG wrote:
set {laSource, laDestination} to {"zzz", "xyz"}
I like that : à la Perl ? Or any other one.
tell application "Mail"
set k to count of messages of mailbox laSource
if k > 0 then
repeat with i from k to 1 by -1
set myMessage to message i of mailbox laSource
if year of (get date received of myMessage) = 2004 then set
mailbox of myMessage to mailbox laDestination
no "move" : only but a change of the myMessage 's mailbox property.
end repeat
end if
end tell
Yvan,
Your script runs.
1) However it takes quite a while with a 10 000 messages mailbox
( This is were this work was initiated from). 261 messages were
"moved" after say 40 minutes, and I "Forced Quit" to let you know and
do some work.
2) coming back to what you raised about the "get" ( which does give
some result :), I ran this :
repeat with myMessage in (get every message of mailbox "myMailbox")
if (year of (get date received of myMessage) = 2006) then move
myMessage to mailbox "essai" --or set mailbox of myMessage to mailbox
"essai"
end repeat
which did move fine : get date received of message id 331045 of
mailbox "myMailbox"
date "lundi 4 septembre 2006 17:47:21"
move message id 331045 of mailbox "France-Musique" to mailbox
"essai"
I see the difference with this :
repeat with myMessage in (messages of mailbox "myMailbox")
if (year of (get date received of myMessage) = 2006) then move
myMessage to mailbox "essai"
end repeat
which raised an error : get date received of item 1 of every message
of mailbox "myMailbox"
date "lundi 4 septembre 2006 17:47:21
"move item 1 of every message of mailbox "myMailbox" to mailbox
"essai"
"Mail got an error: NSInternalScriptError"
I notice that, in the first and correct case, what is handled from
the mailbox is a "message" ( message id 331045 ), while in the second
case it is an "item" of the list "every message of mailbox xxx" -
without any clue of the error.
It looks like I am on the way,
Merci beaucoup.
Francis.
_______________________________________________
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