简体   繁体   中英

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;

I want to send mails via smtp. I've tried to add assembly reference 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); MailMessage mail = new MailMessage(); mail.To.Add(receiver); and SmtpClient smtp = new SmtpClient(); smtp.Credentials = true; SmtpClient smtp = new SmtpClient(); smtp.Credentials = true; It said that mscorlib is missing.

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. Do I need to setup something after installing via NuGet?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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