Title: Re: Automatically move reply messages from Sent Items Folder to same folder as their original
On or near 11/8/03 11:19 AM, Jim Colgate at [EMAIL PROTECTED] observed:

> I am looking for a simple script that can be run manually.
>
> Given my work flow where mail comes into the inbox. I review the message and
> if a reply is needed, generate and send such -- the reply is filed in the
> sent items folder. I then move the original message to the appropriate
> folder for longer term storage. I cannot use the "file with original after
> sending rule" since the original is often still in the inbox when the send
> operation is complete.
>
> I would like the script to determine which messages in the sent items folder
> are related (reply, forward, redirect, resend, etc.) to other messages. Then
> determine which folder the original is currently saved in. And finally move
> the reply message to the same folder as the original. (Some messages could
> logically be filed in more than one long term storage folder, so when it
> comes time to cleanup the sent items folder this brain of mine is incapable
> of guaranteeing that the reply is manually moved to the correct folder.)
>
> Any ideas on how to automatically group all related (original, replies,
> forwards, redirects, resends, etc.) messages together for long term storage
> would be appreciated.
>
>    Jim

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
--------------------------------------------------------------

--
Microsoft MVP for Entourage/OE/Word (MVPs are volunteers)
Allen Watson <[EMAIL PROTECTED]> Entourage FAQ site: <http://www.entourage.mvps.org/>
AppleScripts for Outlook Express and Entourage:
 <http://members.thinkaccess.net/[EMAIL PROTECTED]/Scripts/>
Entourage Help Pages: <http://www.entourage.mvps.org/>

Reply via email to