Title: Re: Script to archive and delete
On 4/3/03 3:08 PM, "Michael D. Johas Teener" <[EMAIL PROTECTED]> wrote:

I’m trying to write a dumb little script that will move a message from my inbox (it’s an IMAP account)
into an archives folder ... I have rules that will move messages automatically into other folders that work fine, except that they leave copies in the IMAP “Deleted Items” folder. I could live with that same functionality (note that I give the messages the category “Delete” so that I can go back and manually remove them from the “Deleted Items” folder later), but I get a an error message when I get to the “duplicate i...” line.

tell application "Microsoft Entourage"
    set theItems to selection
   set deleteCategory to category "Delete"
    set archiveFolder to folder "Archives"
    repeat with i in the theItems
       if class of i is message or class of i is incoming message then
           set read status of i to read
           set category of i to deleteCategory
           duplicate i to archiveFolder
       end if
   end repeat
end
tell

The error message is: "Microsoft Entourage got an error: the message is online and this operation is not yet supported"

You can't move or duplicate messages on IMAP servers because those commands have to return a value (according to Applescript) and IMAP servers cannot be depended on to return a value. A feature request has been made previously to introduce a new command that can move or duplicate on a server without returning a result. Here you don't need that, of course - you're trying to duplicate to a local folder. the fact that you can't is indeed a bug. Another bug is that in Entourage X 'duplicate to' is not working anyway. You first have to just 'duplicate' in place, then move the result. That won't work here either.

What does work as a workaround is to make a new message form the source of the original one in the folder you want. *

By the way, 'class' of a message will never yield 'message': it's either 'incoming message' or 'outgoing message'.  so

    
if class of i is message or class of i is incoming message then

needs to be

    
if class of i is outgoing message or class of i is incoming message then

if that's what you mean. (A draft outgoing message will still be bold even if 'read' - you'd need to set delivery status to sent to unbold it.) And you don't really need to get 'selection' and then test for class - you can just ask for 'current messages' instead. However here we need to know which it is so we can make a new one.

*

    tell application "Microsoft Entourage"
        set theMessages to (current messages)
        repeat with theMsg in theMessages
            set {theClass, theAccount, theSubject, theSource} to theMsg's {class, account, subject, source}
             -- do a routine to replace "/" , ":" in subject by "-", then check no file of same name is in that location
            set dupMsg to make new theClass at folder "Archives" with properties {account:theAccount, source:theSource, read status:read}
            if theClass = outgoing message then set delivery status of dupMsg to sent
            delete theMsg -- or set its category to deleteCategory if you prefer
        end repeat
    end tell

--
Paul Berkowitz

Reply via email to