Let me start by saying that Mail is one of the most difficult applications that I have ever attempted to script. In a nutshell, Mail’s scripting implementation needs a lot of work. Here are a couple of related topics/possible solutions from Apple’s AppleScript forum.
My experience is pretty much limited to Eudora but version 6, which is still in beta, does an excellent job of filtering spam. Eudora is much more scriptable and flexible than Mail. It all depends on what you want from your email client and how much you are willing to pay to get it.
Entourage (from Microsoft) is a very good mail reader and can script almost anything you can think of. (I have a script under perpetual development which takes incoming mail from Yahoo! Groups, strips out advertising, adds links to profiles, kills spam by subject and sender, and then sorts into a definable folder. Iw ould like to get away from Microsoft, but have not found any other mail readers which support scripting to such a degree.