0

The goal of my program is to send an email using visual studio.

Here is my code:

SmtpClient cv = new SmtpClient("smtp.outlook.com", 587);
cv.EnableSsl = true;
cv.UseDefaultCredentials = false;
cv.Credentials = new NetworkCredential("richardteunen2@hotmail.com", "password");
cv.Send("richardteuen2@hotmail.com", "ipadcraze@hotmail.com", "", "Hello");

MessageBox.Show("Done");

System.Net.Mail.SmtpException: The operation has timed out. at System.Net.Mail.SmtpClient.Send(MailMessage message) at System.Net.Mail.SmtpClient.Send(String from, String recipients, String subject, String body)

Any suggestions would be great. Thank you

Evhz
  • 8,852
  • 9
  • 51
  • 69
richard
  • 29
  • 4
  • Possible duplicate of [Send email using Outlook.com SMTP](https://stackoverflow.com/questions/18862932/send-email-using-outlook-com-smtp) – Cᴏʀʏ May 11 '18 at 19:29
  • 1
    The Outlook.com SMTP server is `smtp-mail.outlook.com`. You are also missing some required settings. – Cᴏʀʏ May 11 '18 at 19:29
  • could you please elaborate on missing settings? – richard May 11 '18 at 20:48
  • Try to format the code as good as you can, also errors or exceptions using quote '>'. Its easier to read for other users. – Evhz May 11 '18 at 23:36

1 Answers1

-1

Have you tried to increase the timeout?

SmtpClient cv = new SmtpClient("smtp.outlook.com", 587);
            cv.EnableSsl = true;
            cv.Timeout = 2000;
            cv.UseDefaultCredentials = false;
            cv.Credentials = new 
NetworkCredential("richardteunen2@hotmail.com", "password");
            cv.Send("richardteuen2@hotmail.com", "ipadcraze@hotmail.com", 
"", "Hello");
Jd Savage
  • 41
  • 1
  • 10