问题
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