This is a bit old, but it should get you started: Introduction to Scripting Mail
And we actually have a thread on Getting Started with AppleScript here:
For more information, see the wiki Searching the Forum for Answers section.