Click here to Skip to main content
15,886,060 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Can Any Tell me Through example How to validate an email id
Posted

1 solution

You can do it using Regular expressions.

C#
using System.Text; 

private bool IsValidEmail(string email)        
{            
    string emailRegEx = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|"
                      + @"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*([-][a-z|0-9]+)*\.([a-z]" 
                      + @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
    RegularExpressions.Match match = 
    RegularExpressions.Regex.Match(email, emailRegEx, RegularExpressions.RegexOptions.IgnoreCase);            
    return match.Success;  
}


Read this for more info:
MSDN: How To: Use Regular Expressions to Constrain Input in ASP.NET[^]
 
Share this answer
 
v3

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