Hey Yvan,
I sent a 455K jpg file to my own iCloud account, and I replicated your issue.
The error message I get is: “Mail got an error: AppleEvent handler failed.”
That's the same error I get when I run:
tell application "Mail"
tell (some message viewer whose index is 1)
set preview pane is visible to false
end tell
end tell
I used send-again to send this very same message to one of my normal POP accounts.
My version of your script works fine on that message.
tell application "Mail"
set selectedMessageList to the selection
if length of selectedMessageList = 1 then
set theMessage to item 1 of selectedMessageList
tell theMessage to set messageAttachmentList to its mail attachments
else
beep
end if
end tell
I conclude this is a BUG.
I see no direct workaround using Mail itself. (You can of course resend the message to a different account and rerun the extract script.)
I bet there's a Perl library out there that makes short work of extracting things from email message source, and this might also be possible with ASObjC (Shane?)
But I think the issue needs to be filed as a big hairy BUG.
A little extra testing:
I zipped the jpg (382K) and sent it to my iCloud account – this time the extract script worked.
I duplicated the jpg, zipped it and the original, and sent the larger zip file (765K) to my iCloud account. The extract script worked on this message as well.
I'm thinking the issue is related to files Mail displays in-line, but that is currently just conjecture.