10
我有一個字節數組,它基本上是從數據庫中檢索到的編碼.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;
}