Error conditions

The Mail command fails if the mail server reports an invalid or empty recipient. In that case, the mail message will NOT be sent.

If you want to send mail to a list of recipients, some valid and some invalid, you should use a separate Mail command for each recipient and handle possible errors.

Note

The Mail command only validates recipients against the local mail server. This will catch errors like badly formatted email addresses, but it will not catch "remote" errors, like non-existent remote addresses. In other words: the validation does not guarantee that a message will be delivered at the destination.

Example

Mail command in the script

Refer to Mail command for a description.

Mail
    File("c:\mail\mime.txt")
Host (smtp_server)
From (sender@somewhere.com)
To (somebody@somewhere.com, somebodyelse@somewhere.com)
Attachments("c:\mail\body.txt,c:\mail\body.html,
[logo@aia.nl]c:\images\logo.gif,
[signature@aia.nl]c:\images\signature.jpg"),
c:\mail\invoice.doc,c:\mail\replyletter.doc");

Mime.txt

The content of the file mime.txt.

Subject: Your request dated 18 Jul 2002
To: "F Gonzales" <F.Gonzales@host.domain.com>
Reply-To: "Web Office" <Internet@host.domain.com>

This mail is meant to be read using a MIME-enhanced e-mail client. If you can see this text your client is NOT MIME-enhanced. Please ask your system operator for assistance.

Body.txt

The content of the file body.txt.

Dear Mr. Gonzales,
......
Please find the following documents attached:
- Your invoice.
- A reply letter.
......

Body.html

<html>
<img src = "cid:logo@aia.nl" align="right" border="0">
Dear Mr. Gonzales,<p>
..........
Please find the following documents attached:<br>
<ul>
<li> Your invoice.</li>
<li> A reply letter.</li>
</ul>
.......
With kind regards,
<img src = "cid:signature@aia.nl" border="0">
</html>

Any e-mail client that is MIME enhancements should show the header lines from the mime.txt document and display the content of either the body.txt or body.html file as the body of the e-mail. The choice of which version of the body is shown depends of the preferences of the recipient. A non-MIME enhanced e-mail client will show the MIME message from mime.txt.

MIME-types for attachments are read from the Windows Registry.