I have an aspnetboilerplate template, .netcore & angular (free version). I am trying to find a way to attach a word document to an email using the IEmailSender but cant find the proper way of doing so. Have already checked the Email Sending but there is no hint for attaching file to an email. Does anyone have a sample code that could possibly share with me?
Here is the code snippet to send an email with attachment:
MailMessage mail = new MailMessage
{
Subject = "Subject",
Body = "Message",
IsBodyHtml = true,
To = { "[email protected]"},
From = new MailAddress("[email protected]")
};
mail.Attachments.Add(new Attachment(_env.WebRootPath + "\\pp.jpg"));
_emailSender.SendAsync(mail);