CSharp examples for System.Net.Mail:SmtpClient
Return true when the E-mail address is valid
using System.Text.RegularExpressions; public class Main{ #region IsEmailAddressValid//from w w w . j a v a2 s. com /// <summary> /// Return true when the E-mail address is valid /// </summary> /// <param name="emailAddress"></param> /// <returns></returns> public static bool IsEmailAddressValid(string emailAddress) { if (string.IsNullOrEmpty(emailAddress)) return false; var regex = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase); var matches = regex.Matches(emailAddress); return matches.Count == 1; } }