如何从通过smtp发送的电子邮件附件中获取文件? [英] How do I get a file released from an e-mail attachment that was sent via smtp?

查看:673
本文介绍了如何从通过smtp发送的电子邮件附件中获取文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在发送给人员列表的文件。对于每个人,我也发送第二个文件。我在循环中执行此操作,使用两个附件创建电子邮件对象。我通过smtp发送电子邮件,我有 ServicePoint.MaxIdleTime = 1所以电子邮件会立即发出。我清除并处理附件,将电子邮件对象和smtp对象设置为空。但是,当我去删除文件时(在程序中甚至在Windows资源管理器中手动删除),我得知该文件正由另一个进程使用。我需要什么声明来释放这些文件的保留? (vb.net)

I have a file that is being sent to a list of people.  For each person I am also sending a second file.  I do this in a loop, creating an email object with the two attachments.  I send the email via smtp and I have ServicePoint.MaxIdleTime = 1 so the e-mail goes right out.  I clear and dispose of the attachments, set the email object and smtp object to nothing.  But still, when I go to delete the files (in the program or even manually in windows explorer), I get that the file is being used by another process.  What statement do I need to release the holds on these files?  (vb.net)

推荐答案

如果您使用的对象实现 IDisposable 界面,您可以完成后使用。Dispose()方法。
If the objects you use implement the IDisposable interface you may call the .Dispose() method on all of them when you have finished working with them.


这篇关于如何从通过smtp发送的电子邮件附件中获取文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆