1/// <summary>
2 /// Check if email is in correct format
3 /// </summary>
4 /// <param name="email"></param>
5 /// <returns>True if email is correct, false if not</returns>
6 public static bool CheckEmail(string email)
7 {
8 string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
9 @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
10 @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
11 //string strRegex = @"^(([^<>()[\]\\.,;:\s@\""]+"
12 // + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
13 // + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
14 // + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
15 // + @"[a-zA-Z]{2,}))$";
16
17 Regex re = new Regex(strRegex);
18 return re.IsMatch(email);
19 }