うーん、似たようなことをしたことがあります。添付ファイルごとに、データをバイナリ列として保存し、ファイルのサイズをバイト単位で含む別の列に保存します。データベースから取得するために、次のようなものを書きました(SqlCommandおよびSqlDataReaderクラスを使用):
attachment = new byte[size];
sqlReader.GetBytes(sqlReader.GetOrdinal("attachment"), 0, attachment, 0, size);
System.IO.MemoryStream s = new System.IO.MemoryStream(attachment, true);
s.Write(attachment, 0, attachment.Length);
そして、MailMessage クラス (略して mm) に結び付けられすぎています。
System.IO.MemoryStream s = new System.IO.MemoryStream(attachment, false);
Attachment attached = new Attachment(s, "some file name");
mm.Attachments.Add(attached);
たぶん、これらの抽出物が役立つでしょう!2 つの異なるカスタム クラスからコードをプルしたので、各抽出での MemoryStream オブジェクトが少し扱いにくいです。