Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you do email validation with VB.NET?
Posted
Updated 31-Oct-10 14:20pm
v2
Comments
AspDotNetDev 31-Oct-10 17:35pm    
I deleted your duplicate question. You can update your question to fix typos... you don't need to create duplicates.
AspDotNetDev 31-Oct-10 17:35pm    
Also, this question shows that you've done no work yourself. Which part of "email validation" do you need help with?

If you just want to verify that a string is in proper email format, use regular expressions. For an example, see here:

http://msdn.microsoft.com/en-us/library/01escwtf.aspx[^]

If you want to verify whether the address is valid and active, there's no perfect way to do this. You could send a test email from a specific address, and then check new mail for the from-address that you used, and if you get a bounce email, parse the body to figure out if the bounce is for the email you sent. This assumes that the target host is configured to send back bounce messages.

At a simpler level, you could resolve the MX record for the domain and see if exists. That at least guarantees a valid host. Of course this won't verify the username for you.

And then there are email servers that are configured to swallow emails to non-existent users (this is an anti-spam method to prevent spammers from detecting bad addresses or real ones). Not much you can do about those really.
 
Share this answer
 
v2
A regular expression would be the best solution.

If you want to do a simple test to see if an email is part of a specific domain, you could simply do the following:

IF emailAddress.EndsWith("@yourdomain.com")

where emailAddress is a string containing...the email address.

-Richard
 
Share this answer
 
Start by typing "google" in your browser's address bar.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900