Title: Re: List cleanup
On or near 11/17/03 10:06 PM, Matthew Smith at [EMAIL PROTECTED] observed:

> on 18/11/2003 16:55, Scott Haneda at [EMAIL PROTECTED] wrote:
>
>> I must be on about 30 email mailing lists.  There are about 5 that I don't
>> read too often, and only when there is some issue I need to resolve.  I
>> would love to find a way to creat a rule that would take all messages older
>> than 2 weeks from X folder and move those to the trash.  Is this possible?
>
> You mean a schedule that deletes mail from a specific folder if it is more
> than 14 days old? This is what I do for most mailing list messages.

If you'd like a little more control, this script will delete by age from a selected folder. You can specify the age in days, and also can instruct it to preserve flagged and/or unread messages. It's neatest if you have the 24U Appearance scripting addition installed, but it will work if you don't. Copy and paste into script Editor, save in Entourage Script Menu Items, and run from the Script menu. (May not work in Entourage 2001.)

tell application "Microsoft Entourage"
    set f to ""
    try
        set f to displayed feature of front window
    end try
    if class of f is not folder then
        try
            set f to selection
        end try
        if class of f is not folder then
            display dialog "You must select a folder."
            return
        end if
    end if
    set fName to name of f
    display dialog "Delete messages in folder " & fName & " older than n days? (Enter number of days)" buttons {"Delete", "No, exit"} default answer "7"
    set {btn, txt} to {button returned, text returned} of result
    if btn is "Delete" then
        set nDays to txt as number
        set deldate to (current date) - (nDays * days)
        set startC to count messages of f
        try
            set moreFlags to values returned of (display better dialog ¬
                "Check additional filters you wish to use." fields {{kind:check box, name:"Don't delete if flagged"}, {kind:check box, name:"Don't delete if unread"}})
            set omitFlagged to item 1 of moreFlags is checked state
            set omitUnread to item 2 of moreFlags is checked state
        on error
            display dialog "Keep flagged messages?" buttons {"Yes, Keep flagged", "No, delete anyway"}
            set omitFlagged to {(button returned of result) = "Yes, Keep flagged"}
            display dialog "Keep unread messages?" buttons {"Yes, keep unread", "No, delete anyway"}
            set omitUnread to {(button returned of result) = "Yes, keep unread"}
        end try
        try
            set prog to create progress indicator with properties ¬
                {name:"Delete by Age", closeable:true, indeterminate:true, top message:¬
                    "Deleting " & (nDays) & " day old messages…", bottom message:"Please wait…"}
        on error
            set prog to "None"
            display dialog "Deleting by age, please wait until next message." giving up after 4
        end try
        if omitFlagged then
            if omitUnread then
                delete (every message of f whose (time sent is less than deldate) and (flagged is false) and (read status is read))
            else
                delete (every message of f whose (time sent is less than deldate) and (flagged is false))
            end if
        else
            if omitUnread then
                delete (every message of f whose (time sent is less than deldate) and (read status is read))
            else
                delete (every message of f whose time sent is less than deldate)
            end if
        end if
        if prog is not equal to "None" then close progress indicator prog
        set c to count messages of f
        set nDeleted to startC - c
        display dialog "Deleted " & nDeleted & ", " & c & " messages remaining."
    end if
end tell



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