public static bool IsValidEmailAddress(string sEmail)
{
if (sEmail == null)
return false;
else
return Regex.IsMatch(sEmail, @"
^[-a-zA-Z0-9][-.a-zA-Z0-9]*@[-.a-zA-Z0-9]+(\.[-.a-zA-Z0-9]+)*\.(com|edu|info|gov|int|mil|net|org|biz|name|museum|coop|aero|pro|[a-zA-Z]{2})$",RegexOptions.IgnorePatternWhitespace);
}
That solution will not always work. Your best bet is to try to create a New MailAddress() and catch the exception. If it throws an exception then it is invalid, otherwise assume it is valid.
Reputation Points: 1749
Solved Threads: 735
Senior Poster
Offline 3,948 posts
since Feb 2009