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
100 active users
10134 visitors today
10969 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



I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?