C# SMTPClient Timeout Question

≯℡__Kan透↙ 提交于 2019-12-11 13:58:24

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1474641/c-sharp-smtpclient-timeout-question

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!