I have byte array which is essentially an encoded .docx retrieved from the DB. I try to convert this byte[] to it's original file and make it as an attachment to a mail without having to store it first as file on disk. What's the best way to go about this?
public MailMessage ComposeMail(string mailFrom, string mailTo, string copyTo, byte[] docFile)
{
var mail = new MailMessage();
mail.From = new MailAddress(mailFrom);
mail.To.Add(new MailAddress(mailTo));
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
//Attach the byte array as .docx file without having to store it first as a file on disk?
attachment = new System.Net.Mail.Attachment("docFile");
mail.Attachments.Add(attachment);
return mail;
}