Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Mail script stopped working after Mountain Lion

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


Posted on Sep 7, 2012 8:34 AM

Reply
Question marked as Best reply

Posted on Sep 7, 2012 1:23 PM

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.

9 replies
Question marked as Best reply

Sep 7, 2012 1:23 PM in response to Frinton Fogey

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.

Sep 8, 2012 6:41 AM in response to Pierre L.

Thought you would like an update on my Mail script, ran again this afternoon and it failed with the same message "Mail got an error. AppleEvent timed out." I've tried a Relaunch, Shutdown and Startup, Repair Disk Permissions but to no avail. The time out occurs at 120 seconds regardless of 10 mail messages or 1000. I'm running OS X 10.8.1 Mountain Lion now but this script worked perfectly before on OS X 10.7 Lion so I have no idea what to try next, any ideas?

Sep 9, 2012 6:13 AM in response to Pierre L.

The saga continues. I looked at "with timeout statements", not sure what that has to do with anything, I tried increasing the 'time out' but the script still failed. My script worked perfectly time and time again with Lion but will not work with Mountain Lion. I tried modifying the script from:


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


to:


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


and the script ran successfully but didn't give me the result I wanted. I've seen a lot of discussions about bugs in Mail in Mountain Lion, is there another way to produce the results I want?

Thanks for your patience, I don't know how to proceed further!

Sep 9, 2012 9:30 AM in response to Frinton Fogey

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.

Mail script stopped working after Mountain Lion

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.