Я пытаюсь отправить автоматическое письмо с помощью поддержки Outlook.com smtp. Однако я получаю следующее исключение:Отправить письмо с помощью Outlook.com SMTP
System.Net.Mail.SmtpException: Failure sending mail.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host" Exception while sending email.
Мой код:
public bool SendEmail(MailMessage msg)
{
try
{
SmtpClient smtpClient = new SmtpClient("smtp-mail.outlook.com")
{
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential("userAddress", "userPassword"),
Port = 587,
EnableSsl = true,
};
smtpClient.Send(msg);
msg.Dispose();
smtpClient.Dispose();
return true;
}
catch (Exception exp)
{
Console.WriteLine(exp.ToString());
return false;
}
}
Вы пытались использовать: 'smtp.live.com'? – HK1
Сервер входящей почты: pop3.live.com Сервер исходящей почты (SMTP): smtp.live.com – HiperiX
Да, я также пробовал с smtp.live.com. Но исключение все еще бросает – Andy