Get "mail attachments" fails with "-10000" general error - OS X 10.10.1

Right, but duplicates act as a sort of voting mechanism – the more, the merrier.

point 1 : I sent my own report
At this time it’s not flagged as a duplicate. Maybe because the given details made a difference.
point 2 : At this time the problem is always striking in the late 10.10.2 beta version.

Yvan KOENIG (VALLAURIS, France) vendredi 23 janvier 2015 11:10:07

Hi Yvan, great work thanks!

Warwick
Hong kong

Still no fix from Apple under Yosemite 10.0.4?

Running the simplest script throws a -10000 error for any reference to “mail attachments.” Since the base access to attachments is broken, am I correct in assuming that any and all scripts to automatically save our incoming attachments to a “downloads” folder are impossible?

Simple to reproduce; Select a mail item with attachments and run the following simple script with Scriptp Debugger:
tell application “Mail”
set theMessages to selection
repeat with thisMessage in theMessages
set theAttachments to thisMessage’s mail attachments
end repeat
end tell

I’ve reported it to Apple #22003894

Yes sadly it is not fixed (still problematic) in OSX 10.10.4

It however is an inconsistent circumstance. I share the thought it is definitely “cache” related. The hit and miss is very difficult to set up a test and the information is still the “-10000” event regardless of the syntax used to pull the attachments(s) by message

The assertion error logging is also inconsistent.

I’m looking for a workaround because this error has been an obstruction to some production workflow since we migrated to OS X 10.10 last year

Thanks for adding your experience.

Warwick
Hong Kong

Just to add $.02. I’m having the same problem with this code snippet, which (for now) simply wants to count the number of attachments in the current selection. If each time I just select one message with a single attachment, for some messages the script works, but others throw the dreaded -10000 error. In the code below, with some messages the display dialog with “attachmented” never happens.


    set selectedSize to 0 as integer
    set attachmentCount to 0 as integer

    tell application "Mail"
        try
            set selectedMessages to selection
        end try
    end tell

    set selectedCount to count of selectedMessages

    display dialog "here 1" -- DEBUG

    with timeout of (30 * 60) seconds
        repeat with theMessage in selectedMessages
            tell application "Mail"
                try
                    display dialog "here 1a" -- DEBUG
                    set selectedSize to selectedSize + (message size of theMessage)
                    display dialog "selectedSize: " & selectedSize  -- DEBUG
                    set theAttachments to the mail attachments of theMessage
                    display dialog "attachmented "  -- DEBUG
                    
                    on error errStr number errorNumber
                        display dialog "Error in theAttachments:" & return & ¬
                            "errStr: " & errStr & return & ¬
                            "number: " & number & return & ¬
                            "errorNumber: " & errorNumber
                            
                        error errStr number errorNumber
                end try
            end tell
            set attachmentCount to count of theAttachments
        end repeat
    end timeout


Model: iMac
AppleScript: (Xcode) 2.4
Browser: Chrome 44.0.2403.155
Operating System: Mac OS X (10.10)

Hi Swampman, yes these similar snippets of applescript always yield the same result - the “-10000” apple event issue.

FWIW, it is NOT consistent despite my comment above. Interestingly its point more to a “cache” related scenario. Right now we DONT see this issue. It will occur again soon though.

I’ve upgraded to  OSx 10.10.5 on clients and also the servers and it still happens.

It rather seems to be related to some TIMING or access.

As you point out merely attempting to derive a COUNT of attachments manifests this error.

I am trying to determine what the “assertion” issue is when it happens. No info sadly at this stage.

And… for the story here, this happens ALSO email accounts that are hosted on my own OSx server using OSX server mail server. so it’s unrelated specifically to iCLOUD or any other email server/service. It just seems to manifest itself on OSX in both automator environment and Applescript.

Will keep you posted.

Warwick
Hong Kong

@ Swampman

I ran you snippet after selecting four messages with attachments.

I got this perfect events log :

tell application “Mail”
get selection
end tell
tell application “Script Editor”
display dialog “here 1”
end tell
tell application “Mail”
display dialog “here 1a”
get message size of message id 54087 of mailbox “INBOX” of account “pop SFR ky”
display dialog “selectedSize: 601236”
get every mail attachment of message id 54087 of mailbox “INBOX” of account “pop SFR ky”
display dialog "attachmented "
display dialog “here 1a”
get message size of message id 54161 of mailbox “INBOX” of account “pop SFR ky”
display dialog “selectedSize: 1886562”
get every mail attachment of message id 54161 of mailbox “INBOX” of account “pop SFR ky”
display dialog "attachmented "
display dialog “here 1a”
get message size of message id 54201 of mailbox “INBOX” of account “pop SFR ky”
display dialog “selectedSize: 1919411”
get every mail attachment of message id 54201 of mailbox “INBOX” of account “pop SFR ky”
display dialog "attachmented "
display dialog “here 1a”
get message size of message id 54278 of mailbox “INBOX” of account “pop SFR ky”
display dialog “selectedSize: 1927773”
get every mail attachment of message id 54278 of mailbox “INBOX” of account “pop SFR ky”
display dialog "attachmented "
display dialog “here 1a”
get message size of message id 54276 of mailbox “INBOX” of account “pop SFR ky”
display dialog “selectedSize: 8021568”
get every mail attachment of message id 54276 of mailbox “INBOX” of account “pop SFR ky”
display dialog "attachmented "
display dialog “here 1a”
get message size of message id 54281 of mailbox “INBOX” of account “pop SFR ky”
display dialog “selectedSize: 9974844”
get every mail attachment of message id 54281 of mailbox “INBOX” of account “pop SFR ky”
display dialog "attachmented "
end tell
Résultat :
2

I will be back soon in Yosemite 10.10.5 and will test again in it.

Yvan KOENIG running El Capitan 10.11.0 in French (VALLAURIS, France) jeudi 20 août 2015 14:52:03

I’m back under 10.10.5

As I already posted, I found a mail received thru @mac.com which issue the reported error.

The events log is :

tell application “Mail”
get selection
end tell
tell application “Script Editor”
display dialog “here 1”
end tell
tell application “Mail”
display dialog “here 1a”
get message size of message id 39803 of mailbox “INBOX” of account “iCloud”
display dialog “selectedSize: 10961062”
get every mail attachment of message id 39803 of mailbox “INBOX” of account “iCloud”
display dialog “Error in theAttachments:
errStr: Erreur dans Mail : Le gestionnaire AppleEvent a échoué.
number: number
errorNumber: -10000”
Résultat :
error “Erreur dans Mail : Le gestionnaire AppleEvent a échoué.” number -10000 from «script» to item

The attachment is a 8,006,606 bytes long file.

As I am curious, I will import the message in El Capitan to check if it errors also in it.

Mauybe useful for you:
The Console reported the oddity with :

20/08/2015 15:28:56,521 Mail[259]: *** Assertion failure in -[MCMimeBody dataForMimePart:], /SourceCache/Mail/Mail-2104/MailCore/MIME/MCMimeBody.m:362
20/08/2015 15:28:56,522 Mail[259]: An exception was thrown during execution of an NSScriptCommand…
20/08/2015 15:28:56,522 Mail[259]: This method must be called off the main thread

Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) jeudi 20 août 2015 15:27:06

Back in El Capitan

Maybe a good news.

When I ran the script after selecting the message which failed in 10.10.5, the task was correctly achieved with this events log :

tell application “Mail”
get selection
end tell
tell application “Script Editor”
display dialog “here 1”
end tell
tell application “Mail”
display dialog “here 1a”
get message size of message id 61828 of mailbox “Importation-2/aaa”
display dialog “selectedSize: 10820503”
get every mail attachment of message id 61828 of mailbox “Importation-2/aaa”
display dialog "attachmented "
end tell
Résultat :
1

The mail is not in the iCloud mailbox because I don’t activate my .mac.com account when I am in a beta system.

Yvan KOENIG running El Capitan 10.11.0 in French (VALLAURIS, France) jeudi 20 août 2015 15:57:05

Just to add some eye of newt to this stew:

  1. I’m running the script against messages stored in my inbox, which combines messages from different iMap servers. So I agree the problem is probably not server-specific, although I have to test this by selecting messages I know come from different servers.

  2. But since the problem is sporadic, a limited amount of testing cannot prove the problem is server-specific or that it no longer exists.

  3. Nonetheless, in my limited testing, the problem has been consistent. One message with an attachment always triggered the error, while another message with an attachment never did.

  4. Following a suggestion on this board, I rebuilt the indices for my Mail app. The message that always triggered the error no longer does.

  5. Although not a genuine workaround, here’s how I intend to deal with this issue for the time being. (1) Keep the error trap in place, although modify it to keep track of which messages trigger the error. (2) For messages without attachments, use my app as designed. (3) For messages with attachments, use the error trap to monitor their behavior and deal with problematic messages individually, on a case-by-case basis. (4) Curse Apple frequently :D.

Guys I posted the same thing here on apple forums at https://discussions.apple.com/thread/6782947?start=15&tstart=0.

Some slightly good 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 IMAP server. This is anecdotal only.

This is on OSX 10.10.5 …

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

Step 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.
step 2. accessing that email that now has a new message id since it was moved
step 3. processing that email in Step 2. to “get mail attachments for this_message”
step n.etc … resume the processing using the mail messed id from 2.

It seems that logically MOVING the message and attachments within mail, causes the addressing to the attachments for “count” and “get” to be quite solid.

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 with these 2-3 lines of applescript statements.

(* 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

FWIW. this “-10000” apple event errors for applescript/automator processing of email attachments does NOT occur in OSX V10.11.3.

We have regressed 10.10 any and all workaround code back to OSX 10.9.5 flavours and these work solidly under 10.11.3.

hth someone.

warwick
Hong Kong

Hi Warwick,

Your workaround has rescued a script that I have been having problems with since buying a new Mac running OS 10.11

I was getting the same -10000 error when trying to handle mail attachments. I had thought, after getting some help on my thread, that there must be an issue with some of the mail messages that I was testing it on, as the script still worked on other messages. Believing it to be fixed I went away happy, only to find tonight that the problem had not gone away.

I was running 10.11.3, and still getting the error, which doesn’t coincide with your experience above. I have now updated to 10.11.4 but it is still present.

However, the good news is that your workaround works perfectly and my problem is solved. In my case it is only one script that I needed to fix, but one that I use often to save me a lot of time, that had cause a great deal of frustration when it stopped working.

Thank you so much for posting your solution. It has really saved the day.:cool: