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
101 active users
3623 visitors today
3386 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2016 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


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

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


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