Re: Moving selected messages from one entourage folder to another
Re: Moving selected messages from one entourage folder to another
- Subject: Re: Moving selected messages from one entourage folder to another
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 22 May 2006 22:23:31 -0700
- Thread-topic: Moving selected messages from one entourage folder to another
Avoid 'repeat with a in b' format and use 'repeat with i from 1 to (count
list)' format. And when, as in this case, you are deleting or removing items
of the list as you go along, of course it will skip items. The "trick" then
is to work backwards, from the end towards the beginning of the list ,
'repeat with i from (count list) to 1 by -1'. As you remove items it does
not affect the integrity of the remaining members of the list, which have
not yet been touched.
tell application "Microsoft Entourage"
set theMessages to messages of folder "Inbox"
repeat with i from (count theMessages ) to 1 by -1
set thisMessage to item i of in theMessages
set senderName to display name of sender of thisMessage
if <<condition>> then
set storage of thisMessage to folder "Processed Emails"
end if
end repeat
end tell
Set a variable (theMessages) to messages of folder "Inbox" so they don't
have to be accessed more than once.
If you ever want to run this script on an IMAP folder, it won't work*. But
move thisMessage to folder "Processed Emails"
will work for both local (POP) and IMAP messages and folders in the latest
versions of Entourage 2004 (11.2 and later).
(*The reason is that what's actually happening "behind the scenes" when
Entourage "moves" a messages (or sets its storage property) is that the
original is deleted and a new duplicate created in the new location. With
IMAP, not all IMAP servers can be relied upon to return a result to the
script. Entourage 11.2 has been implemented such that the 'move' command
will re-assign the same ID to the new copy of the message, so the script
doesn't have to wait for the IMAP server to return a result. The same is not
true for setting vthe storage property of an IMAP or Exchange message.)
--
Paul Berkowitz
> From: Susan Mackay <email@hidden>
> Date: Tue, 23 May 2006 14:43:25 +1000
> To: <email@hidden>
> Conversation: Moving selected messages from one entourage folder to another
> Subject: Moving selected messages from one entourage folder to another
>
> (NB: Posted originally on the Applescript-Implimentors list and reposed here
> at the suggestion of that lists moderator)
>
> I want to scan through all of the messages in one Entourage folder and mode
> selected ones to another folder.
>
> My code goes like this:
>
>
> tell application "Microsoft Entourage"
> repeat with ThisMessage in messages of folder "Inbox"
> set SenderName to display name of sender of ThisMessage
> if <<condition>> then
> set storage of ThisMessage to folder "Processed Emails"
> end if
> end repeat
> end tell
>
>
> This works well, except that it skips messages. Looking at the event log,
> the translation of the 'repeat" is into a series of "get xxx of item n of
> every message of folder "inbox" where n is a sequence number from 1 to the
> original number of messages in the folder.
>
> However, as the messages are moved the the new folder, the indexing of the
> remaining messages will change.
>
> I've tried several 'tricks' such as getting the message count and attempting
> to index the messages in reverse order etc, but I still end up with missed
> messages.
>
> What is the "official" way of doing this (I'm very much in "learning mode"
> with all of this Applescript and entourage stuff - and Mac's in general - as
> I've had my MacBook Pro for about 2 weeks).
>
> I can run the script enough times to have the desired effect , but this is
> not 'good style'!
>
> Thanks for the help
>
> Susan
>
>
>
>
> _______________________________________________
> 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
>
_______________________________________________
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