Testing for content of email and moving help

I have the following code, which does not seem to work :

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			repeat with eachMessage in theMessages
				set theText to content of eachMessage as string
				ignoring case
					if theText contains space then -- using space as a test for now
						move eachMessage to mailbox "Inbox"
					end if
				end ignoring
			end repeat
		end tell
	end perform mail action with messages
end using terms from

In Mail I have a rule that moves the incoming message to a folder and runs this applescript. I want to check the body of the message for a few keywords and if found move the message back to my inbox.

I have multiple accounts set up so under my Inbox I have two separate inboxes, A & B. Both A, B also show up under the Sent and Trash categories. When moving the message to the Inbox do I have to specify which inbox ? ie Inbox/A.

Running Lion.


I’m not 100% sure but I think rules are only applied the first time a message arrives. I hope I’m wrong though.