System.Net.Mail.SmtpClient.Send 是否同步?
考虑到 SmtpClient 有一个我没有使用的 SendAsync 方法,因此假设 StmpClient.Send 是同步的是否安全? 我正在使用它发送带有临时文件附件的电子邮件,并想知道之后是否可以立即删除临时附件。
谢谢,罗布。
Considering that SmtpClient has a SendAsync method which I'm not using, is it safe therefore to assume the StmpClient.Send is synchronous? I'm using it to send an email with temporary file attachment and want to know whether I can delete the temporary attachment immediately afterwards.
Thanks, Rob.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,它是同步的。
Yes it's synchronous.
好吧,“发送”到 smtp 服务器是同步的,但如果您试图确保消息到达其预期目的地,那么您就不走运了。 一旦 Smtp 服务器确认收到,SmtpClient 将放弃该操作。
Well, the "send" to the smtp server is synchronous, but if you were trying to make sure the message got to its intended destination, you're out of luck. SmtpClient will wash its hands of the operation as soon as the Smtp server acknowledges receipt.
来自 msdn 文档:“发送将电子邮件消息发送到 SMTP 服务器以进行传送。这些方法在消息传输时会被阻止。”
所以是的,它是同步的。
From the msdn documentation: "Sends an e-mail message to an SMTP server for delivery. These methods block while the message is being transmitted.".
So yes it's synchronous.