The following code used to work, but suddenly refuses to work.
private static void SendMail() { try { var mail = new MailMessage(); var smtpServer = new SmtpClient("smtp.google.com", 587); mail.From = new MailAddress(" catthoor.jc@gmail.com ", "Jasper.Kattoor"); mail.To.Add("YYYY"); mail.Subject = "sup"; mail.Body = "sup"; smtpServer.Credentials = new NetworkCredential(" catthoor.jc@gmail.com ", "XXXX"); smtpServer.EnableSsl = true; smtpServer.Send(mail); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); } }
I get the following error:
System.Net.Mail.SmtpException: Error sending mail. ---> System.Net.WebException: Remote name could not be resolved: 'Smtp.google.com'
I also tried using hotmail instead of gmail, same error. I can still send letters manually. Why does this error suddenly occur? There were no problems with this yesterday.
c # email
Jasper catthoor
source share