I am testing .Net Core MVC, which does not support System.Net.Mail, Mailkit, works well but can't figure out how to send attachments that I have stored in my database as binary. I used the following in MVC 5:
var mail = new MailMessage();
mail.Attachments.Add(new Attachment(new MemoryStream(attachment),
attachmentName, attachmentType));
I would appreciate your suggestions. Thank you
This is probably the easiest solution:
var message = new MimeMessage ();
var builder = new BodyBuilder ();
builder.Attachments.Add (attachmentName, attachment, ContentType.Parse (attachmentType));
message.Body = builder.ToMessageBody ();
This assumes that attachmentName and attachmentType are strings while attachment is a byte[].
Thank you
Thank man!
Most helpful comment
This is probably the easiest solution:
This assumes that
attachmentNameandattachmentTypeare strings whileattachmentis abyte[].