CoverYourASP --> Sending email from a form

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
236 active users
1952 visitors today
2681 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2013 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

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...

Featured sponsor
My favorite resources


New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!


Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!