ドキュメントをサーバーに保存せずに電子メールに添付することはできますか?
以下のコードは、サーバーに保存した後にのみ添付されるものです。私が探しているのは、ドキュメントを最初に保存せずにメールに添付する代わりに、提供されたパスからメールに添付することです。
これは、c# を使用した Visual Studio 2005 です。
if (SaveDocument.HasFile)
{
/* Get a reference to PostedFile object */
string strFileName = Path.GetFileName(SaveDocument.PostedFile.FileName);
/* Save the file on the server */
SaveDocument.PostedFile.SaveAs(Server.MapPath(strFileName));
/* Create the email attachment with the uploaded file */
System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath(strFileName));
/* Attach the newly created email attachment */
message.Attachments.Add(attach);
}