ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 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
65 active users
244 visitors today
485 pages today
how is this done?
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

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

ASP.NET Blog
ASPRSS
ShawThing

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

Selling products online - read how James does it now



See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!


Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!