I have a quite specific problem and wander if somebody encountered this already.
The idea is to write a Apple Mail script to be used in rules, with the purpose of saving the attachment in the emails into a folder on the disk.
All works fine if the account the email is incoming into is not an Exchange type of account. And even these emails are processed OK if I process them by selecting the messages and applying the rule.
But if the script is invoked at the moment email is incoming, and then account type is Exchange, then it breaks claiming it cannot read the attachment (or whichever other) property of the list item.
As it turns out, if I get the class of the list item, normally it is and should be a message class, but in this particular case it is Application class
Here is an example which can show the error
using terms from application "Mail" on perform mail action with messages message_list for rule this_rule try tell application "Mail" set listlength to number of items of message_list as integer repeat with theMessage in message_list set theMessageClass to class of the theMessage set theMessageSubject to subject of theMessage display dialog theMessageClass end repeat end tell on error errMsg number errNum display dialog "error in main " & errMsg & " " & errNum end try end perform mail action with messages end using terms from