C# SMTPClient 超时问题

发布于 2024-08-05 23:01:19 字数 224 浏览 1 评论 0原文

我想知道,您是否真的需要手动增加发送操作的超时才能发送大附件。我阅读了位于此处 它表示超时长度为 100 秒。我想知道是否可以直接告诉它继续运行,直到发现错误或邮件消息发送成功,而不是使用超时?

I was wondering, do you really have to increase the timeout of a send operation manually for sending large attachments. I read the Microsoft documentation located here and it says the timeout length is 100 seconds. Instead of working with timeout, I was wondering if its possible to rather just tell it to continue going until either an error is found or the mail message is sent successfully?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳公公是暖光 2024-08-12 23:01:19

您链接的页面已经给出了答案:使用 SendAsync 方法。来自 SendAsync 文档

要在电子邮件已发送或操作已取消时接收通知,请将事件处理程序添加到 SendCompleted 事件。

SendCompleted 事件需要一个 SendCompletedEventHandler 委托,该委托又接收一个 < a href="http://msdn.microsoft.com/en-us/library/x5x13z6h.aspx" rel="nofollow noreferrer">AsyncCompletedEventArgs 实例,可用于判断发送是否成功。

The very page you link already gives the answer: use the SendAsync method. From the SendAsync documentation:

To receive notification when the e-mail has been sent or the operation has been canceled, add an event handler to the SendCompleted event.

The SendCompleted event requires a SendCompletedEventHandler delegate, which in turn receives a AsyncCompletedEventArgs instance, which can be used to find out whether sending succeeded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文