Do you want help to write the script or do you want someone to write the script for you?? CPAN has many module which can parse emails for you, one very good module is MIME::Parser