【问题标题】:Asp.Net sending outlook email and get this 5.7.57 SMTP Client was not authenticated to send anonymous mail during MAIL FROMAsp.Net 发送 Outlook 电子邮件并获取此 5.7.57 SMTP 客户端未经过身份验证以在 MAIL FROM 期间发送匿名邮件
【发布时间】:2019-06-05 13:06:09
【问题描述】:

我正在使用 asp.net c# 发送 Outlook 电子邮件。

当我运行此程序时,我在 (smtp.Send(fromAddress, toAddress, subject, body);) 处遇到错误,我在网上搜索并尝试解决,但什么都没有。请发送帮助。对此,我真的非常感激。

protected void btn_Click(object sender, EventArgs e)
    {
        string eml = "xxx@mymail.com";
        var fromAddress = "xxx@outlook.com";
        var toAddress = eml;
        const string fromPassword = "password";
        string subject = "Subject testing";
        string body = "Welcome..";
        // smtp settings
        var smtp = new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");
        {
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.UseDefaultCredentials = false;
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential(fromPassword, fromPassword);
            smtp.EnableSsl = true;
            smtp.Credentials = credentials;
        }
        // Passing values to smtp object
        smtp.Send(fromAddress, toAddress, subject, body);
    }

【问题讨论】:

    标签: c# asp.net email outlook


    【解决方案1】:

    在线:

    new System.Net.NetworkCredential(fromPassword, fromPassword)
    

    两个参数都有 fromPassword,而不是用户名和密码

    new System.Net.NetworkCredential(fromAddress, fromPassword)
    

    【讨论】:

    • 哦,那是因为它们具有相同的值。两个参数的值是必须的吗?
    猜你喜欢
    • 2015-08-01
    • 1970-01-01
    • 2019-09-15
    • 2019-10-21
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多