I am trying to create a web application which upon entering your email address and message , sends an email with this information from the email address.
I used this:
try { NetworkCredential login = new NetworkCredential("[email protected]", "password");
System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage();
email.To.Add(new MailAddress("[email protected]"));
email.From = new MailAddress("[email protected]");
email.Subject = "Question";
email.Body = question;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = login;
client.Send(email);
}
catch
{
}
But its giving me an SMTP error.
"Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 209.85.129.111 (209.85.129.111:25), connect error 10051" System.Exception {System.Net.Mail.SmtpException}