Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 电子邮件错误-SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.7.57 SMTP;_C#_Asp.net_Email_Outlook - Fatal编程技术网

C# 电子邮件错误-SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.7.57 SMTP;

C# 电子邮件错误-SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:5.7.57 SMTP;,c#,asp.net,email,outlook,C#,Asp.net,Email,Outlook,我试图通过asp.net应用程序发送电子邮件,但它抛出错误“SMTP服务器需要安全连接,或者客户端未经过身份验证。服务器响应为:5.7.57 SMTP;客户端未通过身份验证,无法在发自[SG2PR0601CA0003.apcprd06.prod.outlook.com]的邮件期间发送匿名邮件。” 1) 通过登录owa(www.outlook.com)检查帐户凭据 2) 请检查下面的链接,因为这将是您问题的解决方案 我已经看到的两个差异如下 -SmtpServer.EnableSsl=true

我试图通过asp.net应用程序发送电子邮件,但它抛出错误“SMTP服务器需要安全连接,或者客户端未经过身份验证。服务器响应为:5.7.57 SMTP;客户端未通过身份验证,无法在发自[SG2PR0601CA0003.apcprd06.prod.outlook.com]的邮件期间发送匿名邮件。”

1) 通过登录owa(www.outlook.com)检查帐户凭据
2) 请检查下面的链接,因为这将是您问题的解决方案

我已经看到的两个差异如下
-
SmtpServer.EnableSsl=true
-
新的SmtpClient(“smtpmail.outlook.com”)

文章中还有一个很酷的部分“使用应用程序密码而不是Outlook.Com帐户密码”

1) 通过登录owa(www.outlook.com)检查帐户凭据
2) 请检查下面的链接,因为这将是您问题的解决方案

我已经看到的两个差异如下
-
SmtpServer.EnableSsl=true
-
新的SmtpClient(“smtpmail.outlook.com”)

文章中还有一个很酷的部分“使用应用程序密码而不是Outlook.Com帐户密码”


下面的代码对我有用

    System.Net.Mail.AlternateView htmlView = null;
        string from = "xxx@outlook.com";
        using (MailMessage mail = new MailMessage(from, txtEmail.Text.Trim()))
        {
            mail.Subject = "Json File";
            htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("<html><body><div style='border-style:solid;border-width:5px;border-radius: 10px; padding-left: 10px;margin: 20px; font-size: 18px;'> <p style='font-family: Vladimir Script;font-weight: bold; color: #f7d722;font-size: 48px;'>Kindly find the Attachment.</p><hr><div width=40%;> <p  style='font-size: 20px;'>Thanks</div></body></html>", null, "text/html");
            mail.AlternateViews.Add(htmlView);
            mail.IsBodyHtml = true;
            System.Net.Mime.ContentType contentType = new System.Net.Mime.ContentType();
            contentType.MediaType = System.Net.Mime.MediaTypeNames.Application.Octet;
            contentType.Name = "New-Assign04.json";
            mail.Attachments.Add(new Attachment(Server.MapPath("~/App_Data/New-Assign04.json"), contentType));
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp-mail.outlook.com";
            smtp.EnableSsl = true;
            NetworkCredential networkCredential = new NetworkCredential("xxx@outlook.com", "xxxxxxxx");   // username and password
            smtp.UseDefaultCredentials = true;
            smtp.Credentials = networkCredential;
            smtp.Port = 587;
            smtp.Send(mail);
        }
System.Net.Mail.AlternateView htmlView=null;
字符串from=”xxx@outlook.com";
使用(MailMessage mail=newmailmessage(from,txtEmail.Text.Trim())
{
mail.Subject=“Json文件”;
htmlView=System.Net.Mail.AlternateView.CreateAlternateViewFromString(

请查找附件。

谢谢”,空,“text/html”); mail.AlternateViews.Add(htmlView); mail.IsBodyHtml=true; System.Net.Mime.ContentType ContentType=新的System.Net.Mime.ContentType(); contentType.MediaType=System.Net.Mime.MediaTypeNames.Application.Octet; contentType.Name=“New-Assign04.json”; Add(新的附件(Server.MapPath(“~/App_Data/new-Assign04.json”),contentType)); SmtpClient smtp=新SmtpClient(); smtp.Host=“smtp mail.outlook.com”; smtp.EnableSsl=true; NetworkCredential NetworkCredential=新的NetworkCredential(“xxx@outlook.com“,“xxxxxxxx”);//用户名和密码 smtp.UseDefaultCredentials=true; smtp.Credentials=网络凭据; smtp.Port=587; smtp.发送(邮件); }


下面的代码对我有用

    System.Net.Mail.AlternateView htmlView = null;
        string from = "xxx@outlook.com";
        using (MailMessage mail = new MailMessage(from, txtEmail.Text.Trim()))
        {
            mail.Subject = "Json File";
            htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("<html><body><div style='border-style:solid;border-width:5px;border-radius: 10px; padding-left: 10px;margin: 20px; font-size: 18px;'> <p style='font-family: Vladimir Script;font-weight: bold; color: #f7d722;font-size: 48px;'>Kindly find the Attachment.</p><hr><div width=40%;> <p  style='font-size: 20px;'>Thanks</div></body></html>", null, "text/html");
            mail.AlternateViews.Add(htmlView);
            mail.IsBodyHtml = true;
            System.Net.Mime.ContentType contentType = new System.Net.Mime.ContentType();
            contentType.MediaType = System.Net.Mime.MediaTypeNames.Application.Octet;
            contentType.Name = "New-Assign04.json";
            mail.Attachments.Add(new Attachment(Server.MapPath("~/App_Data/New-Assign04.json"), contentType));
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp-mail.outlook.com";
            smtp.EnableSsl = true;
            NetworkCredential networkCredential = new NetworkCredential("xxx@outlook.com", "xxxxxxxx");   // username and password
            smtp.UseDefaultCredentials = true;
            smtp.Credentials = networkCredential;
            smtp.Port = 587;
            smtp.Send(mail);
        }
System.Net.Mail.AlternateView htmlView=null;
字符串from=”xxx@outlook.com";
使用(MailMessage mail=newmailmessage(from,txtEmail.Text.Trim())
{
mail.Subject=“Json文件”;
htmlView=System.Net.Mail.AlternateView.CreateAlternateViewFromString(

请查找附件。

谢谢”,空,“text/html”); mail.AlternateViews.Add(htmlView); mail.IsBodyHtml=true; System.Net.Mime.ContentType ContentType=新的System.Net.Mime.ContentType(); contentType.MediaType=System.Net.Mime.MediaTypeNames.Application.Octet; contentType.Name=“New-Assign04.json”; Add(新的附件(Server.MapPath(“~/App_Data/new-Assign04.json”),contentType)); SmtpClient smtp=新SmtpClient(); smtp.Host=“smtp mail.outlook.com”; smtp.EnableSsl=true; NetworkCredential NetworkCredential=新的NetworkCredential(“xxx@outlook.com“,“xxxxxxxx”);//用户名和密码 smtp.UseDefaultCredentials=true; smtp.Credentials=网络凭据; smtp.Port=587; smtp.发送(邮件); }


当我更改SmtpServer.EnableSsl=true时,它抛出错误“服务器不支持安全连接”;尝试了所有这些,我的登录凭据都很好。我可以登录到www.outlook.com,但仍然出现相同的错误。您是否尝试过使用我提到的中的代码?可能创建一个新的测试项目,并将该代码与您的证书一起使用。当我更改SmtpServer.EnableSsl=true时,它会抛出错误“服务器不支持安全连接”;尝试了所有这些,我的登录凭据都很好。我可以登录到www.outlook.com,但仍然出现相同的错误。您是否尝试过使用我提到的中的代码?可能创建一个新的测试项目,并将该代码与您的凭据.Net 4.5版和windows 10一起使用。可能与.Net 4.5版和windows 10版重复。可能与