Title: Re: Automatically move reply messages from Sent Items Folder to same folder as their original
Thanks for the quick reply, Allen,

I removed the “same subject” check code and saved the script in the Entourage Scrip Menu Items folder. I then ran it with all selected in my sent items folder and it moved about half of my messages to my other file folders. I looked through those that were moved and all went to the right place (I set a special category on all messages in the sent items folder before I started so I could find where they went). Great job, this is just what I was looking for.

Those which did not move fell into the following categories:
  1. New outgoing messages with no links. -- as expected.
  2. Messages whose linked item was in the in box folder. --as expected.
  3. Old messages that were still in the sent items folder from the last time I did a complex rebuild of the database where the links were lost of course. -- as expected. However, Entourage still knows it was a reply and provides a button to bring up the original in the yellow header at the top of the message. I am guessing that the Entourage database maintains another pointer between the original and reply that is not scriptable. Too bad.
  4. Messages that were forwards of other outgoing messages. -- since the class test for the link was for incoming messages, this is as expected. However, I changed the class test to “message” in place of “incoming message” and it did not make any difference; the message remains in the sent items folder rather than moving to the folder where I had stored the original message. The hidden Entourage pointer is also active and shows the original.

Do you have any idea why testing for class “message” doesn’t seem to work? Do you know anything about the apparent hidden pointer that Entourage uses and if there is any hope of getting access to that?

Thanks again for your help.

   Jim
 


From: Allen Watson <[EMAIL PROTECTED]>
Reply-To: "Entourage:mac Talk" <[EMAIL PROTECTED]>
Date: Sat, 08 Nov 2003 12:56:01 -0800
To: Entourage mac Talk <[EMAIL PROTECTED]>
Subject: Re: Automatically move reply messages from Sent Items Folder to same folder as their original

I don't think what you are asking for is "a simple script," Jim. If you want it to " determine which messages in the sent items folder are related (reply, forward, redirect, resend, etc.) to other messages," you are basically asking for something that does some kind of comparison between every message in the database with every message in sent items. That's a HUMONGOUS job! You really need some kind of starting point, such as selecting one particular message and then searching for all related items...and that is still a big job, which would likely take more time than you are willing to give to it.

Part of what you want is already done. When you reply to a message, a link is created between the reply and the original. Same when you forward or redirect. So it would not be much of a problem to scan the Sent Items folder, locate anything that has another message linked to it, and then move the message from sent items to the folder containing the linked message. Let me see:

Try running this after selecting all the messages in Sent Items, and see if it does what you want. If you don’t want to verify that the messages have the same subject, just remove that code...

-------------------Move Reply to Original's Folder-----------------

tell application "Microsoft Entourage"
    set theMsgs to current messages
    repeat with theMsg in theMsgs
        set msgSubject to subject of theMsg -- may start with "Re:" or equivalent
        set msgSubject to my stripRE(msgSubject)
        set linkedItems to links of theMsg
        repeat with i from 1 to (count linkedItems)
            set linkedItem to item i of linkedItems
            if class of linkedItem is incoming message and (subject of linkedItem) contains msgSubject then
                set theFolder to storage of linkedItem
                if theFolder is not in box folder then
                    move theMsg to theFolder
                else
                    -- Defaults to moving to sent items folder
                    move theMsg to sent mail folder
                end if
                exit repeat
            end if
        end repeat
    end repeat
end tell

on stripRE(t)
    set oldDelims to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {"re:"}
    set l to text items of t
    set AppleScript's text item delimiters to {""}
    set t to l as text
    set AppleScript's text item delimiters to oldDelims
    repeat while t begins with " "
        set t to text 2 thru -1 of t
    end repeat
    return t
end stripRE
--------------------------------------------------------------

Reply via email to