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("your_____@gmail.com", "password");
System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage();
email.To.Add(new MailAddress("my____email@gmail.com"));
email.From = new MailAddress("your_____@gmail.com");
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}