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

I continued my search.
The messages which issued an error are those containing large attachments which are not embedded in the raw content.
These objects have this kind of descriptor :

Content-Transfer-Encoding: BASE64
Content-Disposition: ATTACHMENT;
filename=P1070542.jpg
Content-Type: IMAGE/JPEG;
name=P1070542.jpg
X-Apple-Content-Length: 991146

I don’t know the exact limit but here are some lengths which gave the error :

1,820,944
1,241,316
991,146
703,180
526,782
189,484

I have a message with an attached Pages package which is embedded with a scheme which I don’t understand :
its header is :

Content-Disposition: ATTACHMENT;
filename=“Menu Rework Sep 2014.pages.zip”
Content-Type: APPLICATION/ZIP;
name=“Menu Rework Sep 2014.pages.zip”;
x-mac-auto-archive=yes
Content-Transfer-Encoding: BASE64

but when the message is displayed, the document appear as a normal Pages document, not a zipped one.
The package is 7,345,701 bytes long,
7,240,724 ones when zipped.

Yvan KOENIG (VALLAURIS, France) dimanche 18 janvier 2015 16:48:48

Hello Yvan, again thank you for your comments and advice. To be very very clear and concise, For you and others reviewing this issue and attempting to derive a resolution or workaround for this issue, I will be VERY SPECIFIC about the scenario to avoid any confusion with the:

  1. syntax, punctuation and usage of the statements by consolidating the issue into a single easy to grasp statement that causes the -10000 Apple Event Hander Error
  2. this error happens when the statement included the term "mail attachments" is use against ANY  Apple OS X MAil.app account with ANY IMAP account on any MAC 10.10.1 system on any user (several) that is accessing on any EMAIL server referenced in the APPLESCRIPT environment and as you point out even  iCloud accounts. (The original error was not drawn in any child accounts as these are not used with this MAIL RULE or Automator script
  3. we maintain our own in-house email server as well under OS X SERVER ,  APPLE OSX Server HOSTED, happens on these too, and this is again reproducible from gmail account if you have to use those blokes.
  4. the type or mime type or size or the number of the attachment is irrelevant . It happens with only one attachment.
  5. the error was appaent initially on OS X 10.10.1 in several email rules under OS X Mail.app.
  6. it is easily reproducible from the script editor or Automator with an active email application
  7. the error manifests itself continually as:

in UI or SCRIPT or as described in OP

and in /var/log/system.log

this statement will ALWAYS fail with -10000 Apple Event Handler

  1. to add to your test case, simply send and email with an attachment to an email account in your Apple mail.app mailbox to account EXAMPLE "your_account_on_a_server_somewhere@your_email_somewhere.com).

In it’s receipt, kick off the Apple Script editor and run list line… AGAIN… use YOUR email account for the string “your_account_on_a_server_somewhere”

tell application "Mail" to set current_mail_account_mailboxes_inbox_first_message_attachments_attachment_count to count of attachments in mail attachments of (last message of mailbox "INBOX" of account "your_account_on_a_server_somewhere")

If readers are not sure of what they have in the way of accounts on the CURRENTLY LOGGED IN USER in their Mail.app simply access the preferences and use the string in the preferences/accounts/account information/ description or simply pull/run/execute this statement in a script editor as:

get every account

Lastly this error is not unique to our macs as others have a similar issue. Sadly is not an local to our own MAC environment.

Cheers and thanks again from Hong Kong
Warwick

I selected every mailboxes (50) then typed command + A so Mail said that 10,503 messages were selected.
One account is an iCloud one (imap)
One is a Gmail one (imap)
Three are SFR ones (pop)
One is a LaPoste one (pop)
I apologize but I must repeat that on my machine, only 24 messages from my account iCloud issue the error #-10000.
Some are in the INBOX mailbox, other are in the Sent Messages of the named account.
Of course, it may be because only messages in my iCloud account have large attachments.

May you try to replace your instruction :

tell application "Mail" to set current_mail_account_mailboxes_inbox_first_message_attachments_attachment_count to count of attachments in mail attachments of (last message of mailbox "INBOX" of account "your_account_on_a_server_somewhere")

by

tell application "Mail" to set current_mail_account_mailboxes_inbox_first_message_attachments_attachment_count to count mail attachments of (last message of mailbox "INBOX" of account "your_account_on_a_server_somewhere")

As far as I know, a mail attachment doesn’t contain an attachment, it is an attachment.

Yvan KOENIG (VALLAURIS, France) lundi 19 janvier 2015 12:03:27

Hi Yvan, many thanks for your reply. Yes I have replaced the script statement copied EXACTLY from your paost nd changed the email account name. I’ve tried this various form of syntax prior to initial posting. I rather think it’s a defect/flaw with Application “mail” and the processing of the terms “mail attachment” in 10.10.1

so… it failed sadly.

tell application "Mail" to set current_mail_account_mailboxes_inbox_first_message_attachments_attachment_count to count mail attachments of (last message of mailbox "INBOX" of account "Gmail - warwick test account")

There is ONLY one email in this test gmail account. The attachment is a 30KB object of compressed, random blob… can be anything.

With my mail.app active (open) , The above statement it fails unfortunately with

/var/syslog/system.log

Looking forward to any other suggestions.

Thanks again Yvan.
warwick
Hong Kong

As I wrote, maybe it’s because it’s the only one containing messages with attachment breaking a “rule” that only my iCloud account is able to issue the error #-10000.

You may send the message which causes the problem on your machine to my gmail account.

My address is : yvankoenig gmail com

After sending this message I will boot in Mavericks.
Some of the messages for which I get the error #-10000 are old enough to be available in the volume using this operating system. I will see if I get the same behavior.

Yvan KOENIG (VALLAURIS, France) lundi 19 janvier 2015 13:50:27

Hi Yvan, again many thanks for your kind offer however I will decline it because the error is unrelated to the actual attachment size, type or number of them.

For example, I can attach a single, modest or outrageous (300x) attachments of various size WITHIN the limited of the EMAIL sendmail attachment size quota, email it and then the processes the RECEIVED INBOX statement we’ve been dealing with in previous post will fail.

I can confirm in the last 10 minutes that I DO NOT GET THE ERROR on OS X 10.9.x or as far back as OS X 10.5. I CONFIRM that the set of applescripts that use these “mail attachment” terms, functions correctly on one of our OS X 10.9.x netboot (complete) test and diagnostic systems.

So seems related to OSx 10.10.x

Looking forward to any further comments.

Thanks again

Warwick
Hong Kong

As I wished to be sure that I will have the “offending” messages in Mavericks, on my Yosemite volume, I moved them from INBOX of iCloud into a “standard” mailbox named “aaa”.
When I was in Mavericks, I imported these messages.

After the import process, under Mavericks, I selected all the messages available in my iCloud INBOX and ran the script : I didn’t got the error #-10000.
Then I selected the imported messages and ran the script : no more error #-10000.

Back under Yosemite, I selected the messages from the mailbox “aaa” and ran the script.
No more error #-10000.
I tried to move back the messages in the INBOX of iCloud account but no luck, some of them moved correctly, others remained in “aaa”.

As I am curious, I forwarded one of the message which gave the error #-10000 to my gmail address.
At this time I didn’t received it.

Yvan KOENIG (VALLAURIS, France) lundi 19 janvier 2015 14:54:30

Hi,

This solved my problem with mail attachments error -10000 in AppleScript and Automator on my MacBook

Step 1: Quit Application Mail and delete files

Envelope Index
Envelope Index-shm
Envelope Index-wal

from Library/Mail/V2/MailData

Step 2: Restart Mail und Rebuild Mail database

cheers

Mario

Hi All,

FYI

I filed a bug report (below) with Apple: Nov. 2014 . Apple closed my Bug report on this as a duplicate
BUG REPORT:
As of 10.9 and 10.10 ( Yosemite) you can no longer access Mail.app’s ‘mail attachments’ from Applescript.

This means you cannot save or count them.
You will 9 times out of 10 get resulting error “error “Mail got an error: AppleEvent handler failed.” number -10000”
This appears to happen for 90% of the emails that are in an inbox, individual or consolidated ones.
This bug is reproducible when using a “get selection” Applescripts
This bug is reproducible when Performing a “Run Applescript” action in the Mail.app mail Rules

Hopefully apple will fix this soon.

Hi Mario,thanks for your comments. I believe you have just been lucky or fortunate that this procedure changed “something” on out mac’s ~/ account that caused data examination form the “mail attachments” code path not to fail on OS X 10.10.1.

Certainly the removal of those Apple Mail indexes (a good old trick) causes a rebuild (which one may do indirectly to a less effective manner) through the Mailbox Application menu.

Our testing has manifested this error 99% of the time with a NEW mail account with a single message or the other extreme a 2001 email box with an inordinate number of messages and attachments.

Yvan made a point of this earlier.

Sadly this is looks still like a DEFECT in the implementation of the Applescript term “mail attachments” in OSx 10.10.1.

Form our experience so far, keep your fingers and legs crossed because this failing symptom will return when you least expect it… good Luck!

Warwick
Hong Kong

Hi Mark, yes I recall running over whilst searching this issue your post or similar somewhere that this issues had been logged with Apple. Thanks for doing this back in November. We have only seen this since December when we migrated all out production stuff from OS X 10.9.5 to 10.10.1.

AN adjuct to this albeit “noise” was that SOME OS X 10.7.x Apple Script mail terms caused -11000 and -10000 failures with “assertion” errors and “thread out of line” messages and Apple resolved this expeditiously at the time. Although, I am surprised that seeing a fair few of us have had this issue that it was not seen during Yosemite beta testing…

I agree with your own findings that this is a DEFECT in the processing of the term “mail attachments”. I’d like a workaround of course.

Alas we will have to wait and deal with our situation manually as we rely somewhat on APPLE Mail rules.

All, thanks again for your comments and ideas.

I will update this thread and close it once a satisfactory resolution is found.

Warwick
Hong Kong

Of late poster twtwtw on  apple discussion forums https://discussions.apple.com/thread/6782947 made mention of a likely mail “cache” issue.

We had looked at something similar and looked again and could not find anything definitive in 10.10.1.

The information is at a recent post at https://discussions.apple.com/thread/6782947 and won’t be duplicated here.

any clues would be graciously accepted.

warwick
Hong Kong

Don’t know why but I was hoping that since apple have screwed some of the commands in JXA , like not being able to get the album art using rawdata of data for iTunes. Then maybe they had done the reverse here.

So tried it.

Mail = Application('Mail')

var theAtt  =Mail.selection()[0].mailAttachments()[0].name()

theAtt 

//--On My Mac mailbox: --> "photo 1.JPG"

//--iCload  mailbox: --> Error -10000: AppleEvent handler failed.

And pretty much the same results. Same email but one stored in mailbox ‘On My Mac’ and one in the inbox (icloud)

On My Mac mailbox: → “photo 1.JPG”

iCload mailbox: → Error -10000: AppleEvent handler failed.

I have had more luck with emails stored in ‘On My Mac’ than ones referenced to the inboxes. But have had the issue there also.

I really do think the issues is not the emails or attachments but how Apple have implemented changes in Mail.app or Applescript

Hi Mark, that’s also very interesting. Thanks for that post. This flaw in the “mail attachment” term processing will have to be addressed by an Apple OS X internal s/w fix and I have resigned to having to wait for it.

BTW for you and other readers the continued thread fro Apple forums user twtwtw has some reasonable views concerning this issue.

The thread is at: https://discussions.apple.com/thread/6782947

Thanks again.

Warwick
Hong Kong

I hope you guys are logging all these problems at bugreport.apple.com. That’s the best way you can try to influence things.

Hi Shane, yes fair point! yeah this has been logged apparently by a few people since November 2014, including one of the people in this thread. Two people have pointed out that it has been accepted or made a DUPLICATE or some terminology that means it has been acknowledged as a defect by Apple.

[whinge] I hope it’s resolved soon OS X 10.10.2 because the production workflows we use from clients has some reliance on this term “mail attachment” in our mail rules.

cheers mate

Warwick
Hong Kong

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