I have trouble creating a simple mock mail sender within an ASP NET 5 project.
Here the method :
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("[email protected]", "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);
}
I have included the dependency 'System.Net.Mail', but a tooltip says that the library is available in DNX 4.5.1 but not in DNX Core 5.0, and the project will not compile.
In my project.json there is :
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}
SmtpClient
is being ported to .Net Core. (You can use packagesearch.azurewebsites.net to find the new NuGet packages, and there isn't one.) Do you need .Net Core? – Ingrowing