AppleScript/ Automator Term "mail attachments" fails with "-10000" general error - OS X 10.10.1

All, There appears to be a very reproducible error "-10000" "Apple Event Handler" regarding the access / use of Apple Mail.app email attachments by the OS X applescript terms "mail attachments" in OS X V10.10.1 yosemite. (2014/2015) .


I'd like to entertain any expertise on the matter. Please realise that the syntax (usage) is correct because my applications using the "mail attachments" term / facility have been in production for 7-8 years and are now inoperable in OS X 10.10.1


Issue: Any Apple Script or Automator object that references "mail attachments" fails with OS return code "-10000" with error info as "Apple event Handler".


For the sake of brevity and to focus on the precise issue, these EXAMPLE script snippets have ready access to the Active Mail.app's the current set of email(s) via OSASCRIPT, Applescript, Automator, Selection or other in var called "processing_email_messages" as :

tell application "Mail" to set processing_email_messages to

... any email or list

Example #1

tell application "Mail" to get count of mail attachments of first item in processing_email_messages

Example #2

if current_email's mail attachments is not {} then

Example #3

tell application "Mail" to get count of the mail attachments in (first item in processing_email_messages)

This error has been reproduced on six independent / different 10.10.1 OS X systems and different users spaces (logons ~/)with the same error symptoms and therefore conclude that this issue is within the current OS X 10.10.1.


Symptom of any of these in any construct:

  1. AppleScripts error "
    Mail got an error: AppleEvent handler failed." number -10000
  2. Automator with nodes Get Selected Mail Messages ->> Get Attachments from Maill Messages

Get Attachments from Mail Messages Failed - Error 1

An error occurred while executing a script: The Operation couldn't be completed. (OSStatus error -10000)

/var/syslog/system.log: these are very consistent.

Mail[49641]: *** Assertion failure in -[MCMimeBody dataForMimePart:], /SourceCache/Mail/Mail-1993/MailCore/MIME/MCMimeBody.m:362

Mail[49641]: An exception was thrown during execution of an NSScriptCommand...

Mail[49641]: This method must be called off the main thread


It appears from my copies web searches that this is not unique to myself as many others have the precise issue that is UNRELATED to syntactic use of Applescript in OSx Mail.app.

I'd appreciate any help or comments on the matter or a workaround would be also very helpful.

Many Thanks

Warwick

Hong Kong

Posted on Jan 17, 2015 8:32 PM

Reply
17 replies

Sep 11, 2015 6:51 AM in response to Warwick Teale

Some slight news on the issue and a simple workaround that can be added to automator script or applescript. It seems the -10000 apple events error and the "assertion" error have a relationship to some failed access to cases on the map server. This is anecdotal only.

We have managed to implement a simple work around that involves using Application "Mail" to

  1. move the mail message being processed to another mail folder in the current mail account or similarly move to another mail account and mailbox.
  2. accessing that email that now has a new message id since it was moved
  3. processing that email in 2. to "get mail attachments for this_message"
  4. etc ... resume the processing using the mail messed id from 2.


For example, this code snippet is framed within Application "Mail", with email account "Production imap account", with an INBOX folder names "transient".


The full reference to the email account and inbox and folder (mailbox "INBOX/transient" of account "Production imap account") is here for example. rather than using a default account. This you can move it anywhere. We have succeeded to also use "On My Mac". The latter is no good for our production work.


NOTE: This wont work using a mail "move" directive in a mail rule because the new mail reference is lost.


This must be done within the script as shown below.


(* move the message and attachments to another mailbox *)

move the current_msg to mailbox "INBOX/transient" of account "Production imap account"


(* address/reference the moved email message - care... it has a Newly created message id! *)

set moved_message to first message in mailbox "INBOX/transient" of account "Production imap account"


(* Re-address the (your) current code_variable with the MOVED email and its attachments. *)

set current_msg to moved_message


(* the existing code continues.*)

tell current_msg

..... the rest if the code you use goes here. et

This has been working solidly in existing workflow now to handle applescript mail attachments. So there are no more "-10000 apple event" errors!


Please post your results for others to see.


warwick

Hong Kong

Mar 7, 2016 1:55 AM in response to Warwick Teale

Guys, some good news regarding the "-10000" Apple Event Handler errors for Mail.app Applescript/automator mail attachment processing that since migrating our systems to  OSX 10.11.3 from  OSX 10.10.5 we have not experienced this problem in any form!

We regressed all the "workaround" applescript code in the production applications that was added to try and circumvent apparent cache ing error with LDAP mail when we first encountered this in OSx 10.10.

Simply, we cannot reproduce the '-10000' apple script error on OSX 10.11.3

HTH

Post your results for others to see

Warwick

Hong Kong

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript/ Automator Term "mail attachments" fails with "-10000" general error - OS X 10.10.1

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