Title: Re: Set Message Account?
On 1/4/02 1:21 AM, "Adam Bailey" <[EMAIL PROTECTED]> wrote:

> On 1/1/02 7:29 PM, Paul Berkowitz <[EMAIL PROTECTED]> wrote:
>
>> On 1/1/02 4:54 PM, "Adam Bailey" <[EMAIL PROTECTED]> wrote:
>>
>>> Is there a way, such as with an AppleScript, to set or change the "Account"
>>> designation of a particular email? Any message I import is without this, and
>>> I'd like to be able to establish it.
>>>
>>> Thanks!
>>
>> Run this script from a Mail (POP) rule for incoming POP account messages, or
>> a Mail (IMAP) rule on incoming IMAP messages, with whatever criteria you
>> want:
>>
>> tell application "Microsoft Entourage"
>>   set theMsg to item 1 of (get current messages)
>>   set account of theMsg to POP account "My Other AccountName" -- or IMAP
>> end tell
>>
>> You have to designate the account type as POP account or IMAP account.
>
> One problem: this only seems to work on one message at a time. If I
> highlight several, only the first will be marked. More importantly, if I set
> a rule to run this script, it doesn't work on *each* message that matches
> the rule. (I'm unclear if it's acting on the first message, or none at all.)

Did you try it to see? You said you wanted it to run automatically from a rule. Rules run on one message at a time.  'item 1 of (get current messages)' always acts on the message being filtered by a rule. (There are about 1000 scripts to prove it!). Since you said you wanted it from a Rule, I presumed you were going to run it from an Enabled rule on an incoming message being downloaded from the net, so that when you replied to it it would go out from a different account.

If, instead, you want it to act on certain messages you select in a folder, when you apply the rule manually, then this again is how the script should be written. That's how rules work.

Now - if what you really want is not a rule but a SCRIPT to act on all the messages in a folder - yes, there is a quicker way. NOT if you only want to it to run on a subset of messages you select - in that case a script would have to go through a laborious repeat loop for each item in the selection. That would actually be quite a bit slower than a Rule applied to each message using the script above.  But if you want to act on ALL the messages in a folder, then run the following script NOT from a rule but directly from the script menu, and it will be a lot faster. (It won't matter if some of the messages are already set to the account you want.) In this case, you must select a folder so that it is displayed in the message pane:

tell application "Microsoft Entourage"
    
    set theFolder to displayed feature of main window
    if class of theFolder is not folder then
        beep 2
        display dialog "You first need to select a folder!" buttons {"OK"} default button 1 with icon 0
        return
    end if
    
    set account of every message of theFolder to POP account "My Other Account"
    
end tell



Scripts can be much more powerful than rules if you know what to do with them.

--
Paul Berkowitz

Reply via email to