我想将存储为 SQL Server 中二进制对象的 PDF 文件附加到电子邮件中,但不在磁盘上创建(临时)文件。
byte[]
我已经有了从 SQL Server 中的二进制字段中提取 PDF 文件作为数组的第一步。
我也有设置的步骤MailMessage
:
MailMessage aMailMessage = new MailMessage();
// set address, subject, body
aMailMessage.Attachments.Add(attachment);
我被卡住的地方是attachment
对象:
Attachment attachment = new Attachment(... what goes here? ...);
的构造函数Attachment
主要接受 a string fileName
(我没有也不想要)或 a System.IO.Stream contentStream
。
所以我的问题是:使用给定的byte[]
数组是否可以Attachment
在磁盘上没有中间文件的情况下创建正确的对象,我必须执行哪些步骤?
先感谢您!