10
본질적으로 DB에서 검색 한 인코딩 된 .docx 인 바이트 배열이 있습니다. 이 바이트 [] 원래 파일로 변환하고 디스크에 파일로 먼저 저장할 필요없이 메일 첨부 파일로 만들려고합니다. 이 문제를 해결하는 가장 좋은 방법은 무엇입니까?바이트 배열을 메일 첨부 파일로 변환하는 방법
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;
}