Deleting a message in Mail.app 7

I get email updates to a webforum I subscribe to every time a post is updated; if a thread goes crazy, I can get 20 messages all saying ˜the thread is updated - click this url to view it: [link to forum thread]'.

I wrote a script to cycle through every email and delete ones which already have the same content as ones we’ve already scanned, and whilst it finds those easily enough, it won’t actually delete them; I’ve tried moving to trash instead of deleting, tried calling themessage via its message id etc, but nothing works, and I wonder if it’s somehting broken in Mail.app 7

set thecontent to ""
tell application "Mail"
	repeat with themessage in (every message of mailbox "Junk" of account "Personal" whose sender is [forum emailer address])
		if thecontent contains content of themessage then 
			delete themessage
		else
			set thecontent to thecontent & content of themessage
		end if
	end repeat
end tell

I get this error (in this case, the first email that repeats and needs deleting is the 4th in the set of emails:

error "Mail got an error: Can't get item 4 of every message of mailbox \"Junk\" of account \"Personal\" whose sender = \"forum emailer address\"." number -1728

Any help people can give would be gratefully received!

Model: Macbook
Browser: Safari 537.74.9
Operating System: Mac OS X (10.8)