• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Move message to another mailbox behaves erratically?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Move message to another mailbox behaves erratically?


  • Subject: Re: Move message to another mailbox behaves erratically?
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 08 Mar 2003 09:01:24 +1100

On Thursday, March 6, 2003, at 9:38 PM, Michael Heinz wrote:

> So, I figured out to set the mailbox property of each message to move
> them between mailboxes. Okay; fine. But things still don't work as
> expected. Here's a code fragment:
>
> tell application "Mail"
> set my_archive to mailbox ArchiveBox
>
> ignoring case
> repeat with cur_rule in CategoryList
> set my_messages to (every message of mailbox ArchiveBox whose
> sender contains (item 1 of cur_rule))
> set new_mailbox to mailbox (item 2 of cur_rule)
> repeat with my_message in my_messages
> display dialog (item 1 of cur_rule) & ": " & sender of
my_message
> as string
> set mailbox of my_message to mailbox (item 2 of cur_rule)
> end repeat
> end repeat
> end ignoring
> end tell
>
> The display dialog is there for diagnostic purposes. If I comment out
> the "set mailbox" line, the script performs as expected. But when I
> try to actually do the move, things quickly go sour. As near as I can
> tell, once a message has been moved, the my_messages list becomes
> corrupt - it starts pointing at the wrong messages! You can see this
> in the display dialog, where you be told that the string "Todd"
> contains the string "Penny", for example.
>
> Can anyone tell me what I'm doing wrong? I'd like to write a script
> that archives and sorts old mail into different bins, and I'm soooo
> close.

My guess would be that Mail is returning references in the form of "message
n of mailbox "Bloggs" of...", where n is a number. But once you move one
message, what was message n is now message (n-1).

Try adding the line:

set my_messages to reverse of my_messages

before the repeat loop, and see if that solves the problem.

It would be preferable if Mail returned more robust references, referring to
messages by id. I see the dictionary lists a "message id" property for
messages and an "id" property for outgoing messages. I wonder if they are
the same thing.

--
Shane Stanley, email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Move message to another mailbox behaves erratically?
      • From: Michael Heinz <email@hidden>
    • Re: Move message to another mailbox behaves erratically?
      • From: Michael Heinz <email@hidden>
References: 
 >Re: Move message to another mailbox behaves erratically? (From: cricket <email@hidden>)

  • Prev by Date: Re: [SE2] Script to copy selection for mail
  • Next by Date: Re: Searching for the equivalent of coercing to type "record"
  • Previous by thread: Re: Move message to another mailbox behaves erratically?
  • Next by thread: Re: Move message to another mailbox behaves erratically?
  • Index(es):
    • Date
    • Thread