Your question reads like an if statement already; so the program logic is there. What you need to do now is put together a fairly elementary control structure and consider the advice that is posted here:
How do I send an email with Perl (including an attachment)?
In reply to Re: Sending mails
by matthewb
in thread Sending mails
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |