当前位置: 首页 > 知识库问答 >
问题:

ASP. Net发送Outlook电子邮件,并获得此5.7.57 SMTP客户端未通过身份验证,以发送匿名邮件期间从邮件

杜俊晤
2023-03-14

我正在用asp发送outlook电子邮件。净c#。

当我运行这个程序时,我在(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);
    }

共有1个答案

华泽语
2023-03-14

排队的时候:

new System.Net.NetworkCredential(fromPassword, fromPassword)

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

new System.Net.NetworkCredential(fromAddress, fromPassword)
 类似资料: