Validate Email

public static class Extensions
{
    public static bool        IsValidEmailAddress(this string s)
    {
        Regex regex = new          Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$");
        return regex.IsMatch(s);
    }
}
Example:
string customerEmailAddress = "test@test.com";
customerEmailAddress.IsValidEmailAddress()

Description

Validate email id

Details

  • Author: john
  • Submitted on: 1/29/2010 3:45:57 PM
  • Language: C#
  • Type: system.mail
  • Views: 2848

Double click on the code to select all.

 

;