简体   繁体   English

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

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

I've added Microsoft.NETCore.Portable.Compatibility NuGet to my Project, but I still cannot using System.Net.Mail; 我已经将Microsoft.NETCore.Portable.Compatibility NuGet添加到了我的项目中,但是仍然无法using System.Net.Mail;

I want to send mails via smtp. 我想通过smtp发送邮件。 I've tried to add assembly reference System.dll. 我试图添加程序集引用System.dll。 In that case it was possible to use System.Net.Mail but then I've got errors in MailMessage mail = new MailMessage(); mail.To.Add(receiver); 在这种情况下,可以使用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); and SmtpClient smtp = new SmtpClient(); smtp.Credentials = true; SmtpClient smtp = new SmtpClient(); smtp.Credentials = true; SmtpClient smtp = new SmtpClient(); smtp.Credentials = true; It said that mscorlib is missing. 它说缺少mscorlib。

I've searched around the whole night but did not found any solution. 我整夜都在搜寻,但没有找到任何解决方法。

It is confusing why it does not work with Microsoft.NETCore.Portable.Compatibility because that includes System.dll as well. 为什么它不能与Microsoft.NETCore.Portable.Compatibility一起使用却令人困惑,因为它还包括System.dll。 Do I need to setup something after installing via NuGet? 通过NuGet安装后是否需要设置某些内容?

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

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