Kenneth Montealto Kenneth Montealto - 1 year ago 89
ASP.NET (C#) Question

How to send Mail Using STMP?

So far I have this CODE for email validation and a Mail to send Using STMPClient 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("");
m.To.Add(new MailAddress(""));
m.Subject = "Try";
m.Body = "TEST";

SmtpClient smtp = new SmtpClient();
smtp.Host = "";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential()
UserName = "",
Password = "********"
smtp.EnableSsl = true;

Answer Source

Change Your smtp.Host = "";

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download