![](/img/trans.png)
[英]Microsoft.Composition 1.0.27 incompatible with .NETCoreApp,Version=v1.0
[英]Error: 'device not Configured' when Sending Email in .NetCoreApp V1.0 using Mailkit
我目前正在我的MAC上使用VS Code開發Asp .Net核心應用程序。 我研究了如何發送電子郵件,因為System.Net.Mail不完全支持,我遇到了Mailkit。 我將以下依賴項添加到我的JSON文件中:MailKit V1.6.0和MimeKit V1.6.0。
但我得到一個錯誤:
var certificate = new X509Certificate2 (@"C:\path\to\certificate.p12", "password", X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential (new ServiceAccountCredential
.Initializer ("your-developer-id@developer.gserviceaccount.com") {
Scopes = new[] { "https://mail.google.com/" },
User = "username@gmail.com"
}.FromCertificate (certificate));
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587); // Error occurs here.
client.Authenticate ("mymail@gmail.com", credential.Token.AccessToken);
client.Send(message);
client.Disconnect(true);
}
我在網上搜索了一個解決方案,但我找不到任何東西。 有沒有人曾經遇到過這個錯誤,如果有的話,你是如何設法修復它的?
謝謝。
嘗試這個:
using System.Net;
namespace TestCase {
public class Program
{
public static void Main ()
{
Dns.GetHostAddressesAsync ("smtp.gmail.com").GetAwaiter ().GetResult ();
}
}
}
我保證失敗並出現完全相同的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.