问题描述
我正在使用 .net 5 从后端向 Outlook 中的同一电子邮件客户端发送电子邮件。我尝试发送到不同的电子邮件,但是,我仍然收到相同的错误消息。使用调试,我发现异常被捕获在代码“client.Send(message);”上。这是出现错误消息的时候。为什么我会收到此错误消息,我该如何解决?
错误信息
> Exception has occurred: CLR/System.Net.Mail.SmtpException
An exception of type 'System.Net.Mail.SmtpException' occurred in softwareapp.dll but was not handled in user code: 'Transaction Failed. The server response was: 5.2.0 STOREDRV.Submission.Exception:OutboundSpamException; Failed to process message due to a permanent exception with message WASCL UserAction verdict is not None. Actual verdict is Suspend,ShowTierUpgrade. OutboundSpamException: WASCL UserAction verdict is not None. Actual verdict is Suspend,ShowTierUpgrade. [Hostname=LNXP265MB0668.GBRP265.PROD.outlook.com]'
at System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode,String serverResponse)
at System.Net.Mail.DataStopCommand.Send(SmtpConnection conn)
at System.Net.Mail.SmtpConnection.OnClose(Object sender,EventArgs args)
at System.Net.ClosableStream.Close()
at System.Net.Mail.MailWriter.Close()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Controllers.ContactUsController.contactUsSubmitForm(ContactUsSubmitForm contactUsSubmitForm) in \Controllers\ContactUsController.cs:line 39
at Microsoft.Extensions.Internal.ObjectMethodExecutor.<>c__displayClass33_0.<WrapVoidMethod>b__0(Object target,Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.VoidResultExecutor.Execute(IActionResultTypeMapper mapper,ObjectMethodExecutor executor,Object controller,Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next,Scope& scope,Object& state,Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterasync()
[HttpPost()]
public void sendEmail()
{
try
{
string _sender = "myemail@outlook.com";
string _password = "password";
SmtpClient client = new SmtpClient("smtp-mail.outlook.com");
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential(_sender,_password);
client.EnableSsl = true;
client.Credentials = credentials;
MailMessage message = new MailMessage(_sender,"myemail@outlook.com");
message.Subject = "c sharp test email";
message.Body = "c sharp body of email";
client.Send(message); //where the code stops working and error message appears up
}
catch (Exception)
{
throw;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)