【发布时间】:2020-07-08 06:39:20
【问题描述】:
我想在 ASP.NET MVC 网站中发送电子邮件,但它不起作用。
我认为问题出在此异常
'client.ServicePoint.Address' 引发了类型为 System.Uri {System.NotSupportedException} 的类型为“System.NotSupportedException”的异常。
代码之后
var client = new SmtpClient("smtp.office365.com", 25)
在此文档https://docs.microsoft.com/en-us/dotnet/api/system.net.servicepoint.address?view=netcore-3.1 中,它说异常是由于“ServicePoint 处于主机模式”。我不知道。
谁能解释一下并告诉我如何解决?
谢谢,
【问题讨论】:
-
真正的问题是我使用的端口号不正确......应该使用587......
标签: asp.net-mvc smtpclient servicepoint