Failure sending mail. Unable to write data to the transport connection

前端 未结 2 1059
刺人心
刺人心 2021-01-12 14:27

I am using a Gmail SMTP server to send mail from VB.Net. Although it sends some emails fine, for some others it returns the following error:

Failure s

2条回答
  •  孤街浪徒
    2021-01-12 15:27

    I was experiencing this same issue recently with SmtpClient.SendMail(MailMessage) being used repeatedly with an email with a 350k attachment. Every 33rd message, the error you gave would occur.

    Turns out our shared component which encapsulated the SendMail functionality was not calling Dispose() on the SmtpClient class when the message was finished sending.

    Adding client.Dispose() to the SmtpClient instance cleared the problem right up and now messages go out no problem - hundreds of them (and yes they're legitimate product notifications to our customers, not spam) ;)

提交回复
热议问题