You are viewing a plain-jane printable version of http://CoverYourASP.com/ContactDescr.asp.
See how this was done

 

How to send email from a form continues to be one of the top asked questions on search engines and ASP sites like mine.

I've always offered you the source code for my forms (in fact you can download the entire site), but it's now time to step through the code with you and explain the code in more detail.

Do you know how to write <form>'s with ASP? If not, read that first.

Let's look at the first step after the form has been submitted - validating the inputs:

// has the form been submitted?
if ( bSubmitted )
{
   // get the data from the form...
   sEmail = ''  + Request.Form ( "email" );

   // validate the email address and moan if it fails
   if ( sEmail != '' && !IsValidEmail ( sEmail, hexVeLevelDns ) )
   {
      // pretend the form hasn't been sent yet
      bSubmitted = false;
   }
}

The email address is retrieved from the form, and if not blank, it is sent into IsValidEmail( ) to be validated.

If the function returns false then I reset bSubmitted which causes the form to be re-displayed. But what does IsValidEmail( ) do?

Part 2: The IsValidEmail( ) function...