found and implemented the following:
*1) Issue causing the symptom:*
Looks like's there's a circumstance after OSX 10.5 when running an applescript from a mail.app rule. This issue is where one calls the apple script and within the applescript performs some processing using the mail.app ( Tell application "mail") or performing direct references/methods to it whilst inline. The error message notes this as +the method must be called of {out of??} the main thread+.
After some long time looking I found these links , the first one from Horito was most helpful and obvious. (thanks mate).
http://discussions.apple.com/message.jspa?messageID=12068548
and this eon to which he refers....
http://hints.macworld.com/article.php?story=20080314184621760
Simply all that is needed it ro make the mail.app specific methods into another method outside the main call ofthe applescript called by the mail rule.
*2) Here's what i did:*
Took the main bits and pieces of the apple script main and made a handler with all the mail.app stuff in it
global some
global_for_later1
global another
global_for_later2
using terms from application "Mail" -- directly called from MAIL.app rule
on perform mail action with messages bunch
of_msgs_from_mailrule
(* any other set up initialisation stuff here *)
(* call main handler outside of main thread to avoid error "
* Assertion failure in -[MimeBody dataForMimePart:], /SourceCache/Message/Message-1082/Message.subproj/MIME.subproj/MimeBody.m:422 This method must be called off the main thread " *)
my main
mail_script_handler(bunch_of_msgs_from_mailrule)
end perform mail action with messages
end using terms from
(* _ avoid assertion failure error messages for mail rule applescripts _*)
(* _ move all the work from the main thread _*)
using terms from application "Mail" -- using mail app defs
on main
mail_script_handler(bunch_of_msgs_from_mailrule)
(* put goodies here .. *)
(* get mail attachments and sav them etc *)
(* use other services / handlers ... tell application "database Events" etc etc *)
return 0
end main
mail_scripthandler -- end of the main thing
end using terms from
Workround? : yes works ok and not any effort to do really. Ths circumvention stops the messages coming out in the /var/console such as :
+05/01/2011 6:04:58 PM Mail[4121]
* Assertion failure in -[MimeBody dataForMimePart:], /SourceCache/Message/Message-1082/Message.subproj/MIME.subproj/MimeBody.m:422+
+This method must be called off the main thread+
(
+ 0 Message 0x00007fff866f06e4 -[MFAssertionHandler _handleFailureWithPreamble:description:arguments:] + 137+
+ 1 Message 0x00007fff866f0649 -[MFAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 220+
so I guess the circumstance doesn't hap[en.
I will leave this open for a while in case anyone has some other fixes.
Thansk to Hiroto in
http://discussions.apple.com/message.jspa?messageID=12068548 for his great post on this issue.
HTH
Happy New Year from Hong Kong!.