簡體   English   中英

無法通過Hotmail連接到遠程服務器

[英]Unable to connect to the remote server with hotmail

我正在嘗試將電子郵件發送到我自己的hotmail,但是發生此錯誤:

無法連接到遠程服務器

遵循發送電子郵件的代碼方法:

public void SendEmailToClient(string email, string subject, string content)
{
    SmtpClient smtpClient = new SmtpClient();
    NetworkCredential basicCredential = new NetworkCredential("thiago.friedman@hotmail.com", "123");
    MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress("thiago.friedman@hotmail.com");

    smtpClient.Port = 25;
    smtpClient.Host = "smtp.live.com";
    smtpClient.UseDefaultCredentials = false;
    smtpClient.Credentials = basicCredential;

    message.From = fromAddress;
    message.Subject = subject;
    message.Body = content;
    message.To.Add("thiago.friedman@hotmail.com");

    try
    {
        smtpClient.Send(message);
    }
    catch (Exception ex)
    {
        Response.Write(ex.Message);
    }
}

會是什么呢?

在添加以下內容后對我有用:

 smtpClient.Port = 587;
 smtpClient.EnableSsl = true;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM