The one part you need is a command line SMTP emailer. Here it is -> http://sourceforge.net/projects/blat

This is not an offer to write your script. Just supplying the critical component to make it work.

Bob