So far I have this CODE for email validation and a Mail to send Using SMTPClient However it won't work ,it won't send to the gmail stated. But i think there is no problem with my code. I need some help to make a way for sending Mail .
string validEmailPattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|" + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)" + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$"; Regex ex = new Regex(validEmailPattern, RegexOptions.IgnoreCase); if (ex.IsMatch(TextBox1.Text)) { MailMessage m = new MailMessage(); m.From = new MailAddress("[email protected]"); m.To.Add(new MailAddress("[email protected]")); m.Subject = "Try"; m.Body = "TEST"; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential() { UserName = "[email protected]", Password = "********" }; smtp.EnableSsl = true; smtp.Send(m);