Skip navigation

Mail script stopped working after Mountain Lion

735 Views 9 Replies Latest reply: Sep 9, 2012 9:30 AM by Pierre L. RSS
Frinton Fogey Level 1 Level 1 (0 points)
Currently Being Moderated
Sep 7, 2012 8:34 AM

I have been using a script to extract mail messages for analysis but since changing to Mountain Lion it has stopped working. The script issues a message "Mail got an error. AppleEvent timed out." I have tried running with small test mailboxes but still the same result. Not sure what to do next!

Any help gratefully received.

 

tell application "Mail"

          tell mailbox "CS Notepad"

                    tell mailbox "Test"

                              set CS_Messages to content of every message that subject contains "Daily Summary"

                    end tell

          end tell

end tell

 


  • Pierre L. Level 4 Level 4 (3,860 points)

    I have tried your script, just replacing "CS Notepad", "Test" and "Daily Summary" with other text values. It seems to work flawlessly under OS X 10.8.1. How long must you wait before the script issues the error message? Is there a huge number of messages in your mailboxes?

     

    Have a look at “with timeout Statements" in the AppleScript Language Guide.

     

    Message was edited by: Pierre L.

  • Pierre L. Level 4 Level 4 (3,860 points)

    My pleasure. Thanks for your feedback.

  • Pierre L. Level 4 Level 4 (3,860 points)

    any ideas?

     

    As I wrote in my first post, I would have a look at “with timeout Statements”, in the Control Statements Reference section of the AppleScript Language Guide.

  • Pierre L. Level 4 Level 4 (3,860 points)

    Try this:

     

    set theContents to {}

    tell application "Mail"

        tell mailbox "CS Notepad"

            tell mailbox "Test"

                set CS_Messages to every message that subject contains "Daily Summary"

                repeat with thisMessage in CS_Messages

                    copy content of thisMessage to the end of theContents

                end repeat

            end tell

        end tell

    end tell

    theContents

  • Pierre L. Level 4 Level 4 (3,860 points)

    Brilliant, works every time!

    Actually, you were the one who found the solution by trying the following statement:

        set CS_Messages to every message that subject contains "Daily Summary"

     

    Have you any idea why my original script stopped working, just like to know to stop this happening again.

    Since the original script has always worked flawlessly on my computer under OS X 10.8.1, the only thing I can think of would be another application interfering with Mail or AppleScript in your system.

     

     

    By the way, the following version of the script might be somewhat faster when you have a huge number of messages in your mailbox:

     

    set theContents to {}

    set theContentsRef to a reference to theContents

    tell application "Mail"

        tell mailbox "CS Notepad"

            tell mailbox "Test"

                set CS_Messages to every message that subject contains "Daily Summary"

                repeat with thisMessage in CS_Messages

                    copy content of thisMessage to the end of theContentsRef

                end repeat

            end tell

        end tell

    end tell

    theContents

     

    See the AppleScript Language Guide, Class Reference, list (p. 110 in the PDF version) : “For large lists, it is more efficient to use the a reference to operator when inserting a large number of items into a list, rather than to access the list directly.”

     

    Message was edited by: Pierre L.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (1)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.