【发布时间】:2016-01-29 16:04:48
【问题描述】:
在我的网站中,用户从他的系统上传一些文件并发送电子邮件。
try
{
if(Request.Files!=null)
{
//save the file to some temp location
//Attach the file to email & send
}
}
catch(Exception ex)
{
//log exception
}
finally
{
//delete the file from temp location
System.IO.File.Delete(attachmentLocation);
}
但是如果电子邮件发送失败,那么我可以删除文件,但如果电子邮件发送成功,则会出现异常
文件 test.pdf 不能被删除,因为它被另一个进程使用了
是否可以在不保存的情况下附加文件?
如果不能,那么在发送电子邮件后如何删除文件?
仅供参考:- 这是一个 AJAX 调用。
【问题讨论】:
-
问题不在于您显示的代码。显示邮件发送和文件删除代码。
-
最后 { System.IO.File.Delete(attachmentLocation);}
-
请在您的帖子中编辑代码添加 - 在评论中通常很难阅读
-
现在检查..sn-p
标签: c# asp.net email email-attachments