AppleScript for Mail Rule: What is the problem?

hello,
I am trying to write an AppleScript that works with Mail.app so that whenever the conditions of this rule are satisfied, the AppleScript will run using the triggering message. Obviously, I will add to this skeleton later, but I have been trying to debug this for a while, and I am not really getting anywhere… what is the problem preventing the script from running?

Condition(s) in Mail.app for this rule: Every message


using terms from application "Mail"
	
	on perform mail action with messages message_list for rule this_rule
		
		tell application "Mail"
			display dialog "Running Rule AppleScript!"
			
			repeat with received_message in message_list
				
				set theSubject to (the subject of received_message) as text
				display dialog theSubject
				
			end repeat
			
		end tell
		
	end perform mail action with messages
	
end using terms from

Try flipping the “using terms from” and “on preform” lines and see how that works out.

Hi,

Apple Mail does not allow user interaction (like display dialog) in mail rules

that makes sense, and would definitely be the cause of this problem: but why does Apple have such a… stupid rule? Not to mention, how are we supposed to know that? Just from being told by people (like you told me)? That really cripples the language… wow.

It’s actually not AppleScript’s fault; it’s Mail that causes the problem.