【问题标题】:Sending an email through outlook's smtp server通过 Outlook 的 smtp 服务器发送电子邮件
【发布时间】:2016-02-09 10:27:06
【问题描述】:

我进行了广泛的研究,但没有找到可以解决我当前问题的有效解决方案。我想使用他们的 SMTP 服务器通过我的 windows live 电子邮件发送电子邮件。我得到了错误:

“邮箱不可用。服务器响应为:5.7.3 请求的操作已中止;用户未通过身份验证”

我尝试使用我的防火墙,尝试在我的帐户中启用 SMTP 设置,以及我在本网站和其他网站上找到的其他几个解决方案,但没有任何效果。在我的 Outlook/Windows 帐户的最近活动中,我没有看到 SMTP 访问,只有我当前的登录,即使它说我正在连接。

我不反对使用另一个 SMTP 服务器 我正在使用 C#/ASP.NET 这是我的代码:

        public static void Email(string name, string recipient, string address, string email, string info)
    {
        MailMessage mailMsg = new MailMessage();
        mailMsg.To.Add(new MailAddress(email));
        // From
        MailAddress mailAddress = new MailAddress("user@live.com");
        mailMsg.From = mailAddress;

        //Content
        mailMsg.Subject = "Secret Santa";
        mailMsg.Body = name + ", your target is " + recipient + ". Please spread the holiday cheer with a soft cap of $20! From an automated mail service";

        //SmtpClient
        SmtpClient smtpConnection = new SmtpClient("smtp.live.com", 587);
        smtpConnection.Credentials = new System.Net.NetworkCredential("user@live.com", "password");
        smtpConnection.UseDefaultCredentials = true;

        smtpConnection.EnableSsl = true;
        smtpConnection.DeliveryMethod = SmtpDeliveryMethod.Network;
        smtpConnection.Send(mailMsg);
    }

【问题讨论】:

标签: c# asp.net email outlook smtp


【解决方案1】:

试试下面的代码:

smtpConnection.Credentials = new System.Net.NetworkCredential("user@live.com", "password");

smtpConnection.UseDefaultCredentials = true;

您提供自己的身份验证凭据,因此您必须将 UseDefaultCredentials 设置为 false。否则SmtpClient 无法进行身份验证,您会收到错误消息。

【讨论】:

    猜你喜欢
    • 2018-10-17
    • 1970-01-01
    • 2017-05-19
    • 2012-03-21
    • 2016-12-18
    • 1970-01-01
    • 1970-01-01
    • 2014-10-27
    • 1970-01-01
    相关资源
    最近更新 更多