簡體   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