SmtpClient,无法从传输连接中读取数据:net_io_connectionclosed. [英] SmtpClient, Unable to read data from the transport connection: net_io_connectionclosed.

查看:301
本文介绍了SmtpClient,无法从传输连接中读取数据:net_io_connectionclosed.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我深入解释吗?

Can somebody give me a deep explain about this?

方案1、3将出现异常,错误消息将类似于无法从传输连接读取数据:net_io_connectionclosed.",

Scenario 1, 3 will get exception, the error message will be like "Unable to read data from the transport connection: net_io_connectionclosed.",

但方案2可以正常工作.

but Scenario 2 works fine.

方案1:

MailMessage消息=新的MailMessage();
message.IsBodyHtml = false;
message.From = new MailAddress(" abc@def.com ");
message.To.Add(new MailAddress(" abc@def.com ")));
message.Subject ="subject test";
message.Body =身体测试";

MailMessage message = new MailMessage();
message.IsBodyHtml = false;
message.From = new MailAddress("abc@def.com");
message.To.Add(new MailAddress("abc@def.com"));
message.Subject = "subject test";
message.Body = "body test";

SmtpClient smtp =新的SmtpClient("def.com");
smtp.ServicePoint.MaxIdleTime = 90000;
smtp.Timeout = 90000;

SmtpClient smtp = new SmtpClient("def.com");
smtp.ServicePoint.MaxIdleTime = 90000;
smtp.Timeout = 90000;

smtp.Send(message);//成功发送第一封电子邮件

smtp.Send(message);//send out the first email successfully

System.Threading.Thread.Sleep(70000);

System.Threading.Thread.Sleep(70000);

smtp.Send(message);//第二封电子邮件无法发送

smtp.Send(message);//the second email can't be send out

方案2:

MailMessage消息=新的MailMessage();
message.IsBodyHtml = false;
message.From = new MailAddress(" abc@def.com ");
message.To.Add(new MailAddress(" abc@def.com ")));
message.Subject ="subject test";
message.Body =身体测试";

MailMessage message = new MailMessage();
message.IsBodyHtml = false;
message.From = new MailAddress("abc@def.com");
message.To.Add(new MailAddress("abc@def.com"));
message.Subject = "subject test";
message.Body = "body test";

SmtpClient smtp =新的SmtpClient("def.com");
smtp.ServicePoint.MaxIdleTime = 60000;
smtp.Timeout = 60000;

SmtpClient smtp = new SmtpClient("def.com");
smtp.ServicePoint.MaxIdleTime = 60000;
smtp.Timeout = 60000;

smtp.Send(message);//成功发送第一封电子邮件

smtp.Send(message);//send out the first email successfully

System.Threading.Thread.Sleep(70000);

System.Threading.Thread.Sleep(70000);

smtp.Send(message);//第二封电子邮件可以成功发送

smtp.Send(message);//the second email can be send out successfully

方案3:

MailMessage消息=新的MailMessage();
message.IsBodyHtml = false;
message.From = new MailAddress(" abc@def.com ");
message.To.Add(new MailAddress(" abc@def.com ")));
message.Subject ="subject test";
message.Body =身体测试";

MailMessage message = new MailMessage();
message.IsBodyHtml = false;
message.From = new MailAddress("abc@def.com");
message.To.Add(new MailAddress("abc@def.com"));
message.Subject = "subject test";
message.Body = "body test";

SmtpClient smtp =新的SmtpClient("def.com");
smtp.ServicePoint.MaxIdleTime = 60000;
smtp.Timeout = 60000;

SmtpClient smtp = new SmtpClient("def.com");
smtp.ServicePoint.MaxIdleTime = 60000;
smtp.Timeout = 60000;

smtp.Send(message);//成功发送第一封电子邮件

smtp.Send(message);//send out the first email successfully

int i = 0;//在调试模式下,在此处停留70秒钟,然后运行到最后

int i = 0;//in debug mode, stop here for 70 seconds, and then run to the end

smtp.Send(message);//无法发送第二封电子邮件

smtp.Send(message);//the second email can't be send out

推荐答案

埃里克,

我已将此主题移至专门的论坛以获取更多回复.

I have moved this thread to a dedicated forum for more responses.

谢谢.

最好的问候


这篇关于SmtpClient,无法从传输连接中读取数据:net_io_connectionclosed.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆