Parsing an Email Address
There are many reasons that a website would want to take in an email address. It might be for a newsletter or for a response to a question. Make sure the email address is valid!
It's not that most users will deliberately give you a bad email address. They're trying to subscribe to your newsletter, or send you information after all! But web users are not always the best typists. If they make a typo or mistake, they might not even realize it. Here are some steps you can take to ensure you are able to contact them with the information they want.
* Give them a big enough form field
You would think this might be obvious! But some websites give their users tiny little 2-character spots in which to type a long email address. If the user types something wrong, they aren't able to see it! Give your users as much space as humanly possible to type their email address in. Some users have extremely long addresses, like email@example.com.
* Trim out all spaces
Users often put in spaces by mistake, something like janedoe @ aol.com. They do it without thinking. Your mail server will choke on that, though! Do a simple
email = replace(email, " ", "")
command to turn all spaces into nothing. That probably takes care of 50% of typical user errors.
* Give an error if no @ or . found
All email addresses must have a @ as the separator and at least one . in the server name. Use InStr to make sure there really is a @ and a . in that email address. If one or both is not found, give the user an error and have them try again.
* Help AOL Users
For some reason, it seems that AOL users often have trouble with the ".com" part of their email address. They put in aol.con or aol.co or even just aol without anything else. If you see @aol. as a string in the email, and what follows it is not the letters COM, it might be helpful to change that for them.
* Sent a Thank You
One of the easiest ways to ensure an email address works is to use it immediately. Send the user a thank you letter back in the processing page, and then put a message on the screen telling the user you just sent them that letter. Tell them that if they did NOT get the thank you letter, that they should check the email address they entered, or check the spam filters. That way, when you send your actual response or newsletter, you have at least half a chance of it getting to them.
ASP Newsletter Code