Here is my code:
MailAddress to = new MailAddress("[email protected]");
MailAddress from = new MailAddress("[email protected]");
MailMessage message = new MailMessage(from, to);
message.Subject = "Message du siute as-quebec.net de: " + EmailToSend.Email;
message.Body = EmailToSend.Message;
SmtpClient client = new SmtpClient("smtp.live.com");
client.Credentials = new System.Net.NetworkCredential("[email protected]", "PASSWORD");
client.Send(message);
I have this error:
System.Net.Mail.SmtpException : 'Failure sending mail.'
ExtendedSocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or an established connection failed because the connected host has failed to respond.
Some ideas what I'm doing wrong?
When using SmtpClient, if one specifies the incorrect value for SMTP server name (ie: SmtpClient.Host), one receives the following error message:
According to POP, IMAP, and SMTP settings:
SMTP Settings
Also, ensure that you call Dispose for anything that has a Dispose method. The easiest way to do this, is with a using statement (or using declaration).
Try the following: