繁体   English   中英

无法在ASP.NET MVC项目中使用System.Net.Mail

[英]Cannot use System.Net.Mail in ASP.NET MVC Project

我已经将Microsoft.NETCore.Portable.Compatibility NuGet添加到了我的项目中,但是仍然无法using System.Net.Mail;

我想通过smtp发送邮件。 我试图添加程序集引用System.dll。 在这种情况下,可以使用System.Net.Mail,但随后MailMessage mail = new MailMessage(); mail.To.Add(receiver);出现错误MailMessage mail = new MailMessage(); mail.To.Add(receiver); MailMessage mail = new MailMessage(); mail.To.Add(receiver); SmtpClient smtp = new SmtpClient(); smtp.Credentials = true; SmtpClient smtp = new SmtpClient(); smtp.Credentials = true; 它说缺少mscorlib。

我整夜都在搜寻,但没有找到任何解决方法。

为什么它不能与Microsoft.NETCore.Portable.Compatibility一起使用却令人困惑,因为它还包括System.dll。 通过NuGet安装后是否需要设置某些内容?

尝试使用此方法发送邮件: 如何在ASP.NET C#中发送电子邮件

尝试此操作以缺少mscorlib(也许尝试导入到依赖项): mscorlib代表什么?

或者: https : //developercommunity.visualstudio.com/content/problem/22337/have-problem-with-assembly-mscorlib.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM