Skip to content

Instantly share code, notes, and snippets.

@mikebrind
Last active March 26, 2019 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebrind/14e749aded8a6bbfe9df4d3e92b9a296 to your computer and use it in GitHub Desktop.
Save mikebrind/14e749aded8a6bbfe9df4d3e92b9a296 to your computer and use it in GitHub Desktop.
using System.Net.Mail;
using System.Threading.Tasks;
namespace RazorPartialToString.Services
{
public class DemoEmailService : IEmailService
{
public async Task SendAsync(string email, string name, string subject, string body)
{
using (var smtp = new SmtpClient())
{
smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
smtp.PickupDirectoryLocation = @"c:\maildump";
var message = new MailMessage
{
Body = body,
Subject = subject,
From = new MailAddress(email, name),
IsBodyHtml = true
};
message.To.Add("contact@domain.com");
await smtp.SendMailAsync(message);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment