我无法在 ASP NET 5 项目中创建简单的模拟邮件发件人。
这里的方法:
public static Task SendMail(string Email, string Subject, string Body)
{
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = "C:\\TMP";
MailAddress from = new MailAddress("jane@contoso.com", "Jane " + (char)0xD8 + " Clayton", System.Text.Encoding.UTF8);
MailAddress to = new MailAddress(Email);
MailMessage message = new MailMessage(from, to);
message.Body = Body;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Subject = Subject;
message.SubjectEncoding = System.Text.Encoding.UTF8;
client.Send(message);
message.Dispose();
return Task.FromResult(0);
}
我已经包含了依赖项“System.Net.Mail”,但工具提示说该库在 DNX 4.5.1 中可用,但在 DNX Core 5.0 中不可用,并且该项目将无法编译。
在我的 project.json 中有:
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}