无法从传输连接中读取数据:net_io_connectionclosed smtp.office365.com

发布于 2025-02-02 03:32:18 字数 1972 浏览 3 评论 0原文

我有一个由Microsoft Visual Studio 2008开发的Windows应用程序桌面(C#)。该应用程序将SMTPCLEINT用于系统生成的电子邮件服务。 SMTP.Office365.com通过电子邮件地址使用的电子邮件服务。它运行良好,但最近表现出一个例外。

无法从传输连接中读取数据:net_io_connectionclosed。

我试图解决几天,但不可能。

代码:

  dt_email = dh.select_table("Select * from dbo.tblEmailInfo");
                    try
                    {
                        MailMessage mM = new MailMessage();
                        mM.From = new MailAddress(dt_email.Rows[0][1].ToString());

                        mM.To.Add(this.dgvAction.CurrentRow.Cells[23].Value.ToString());
                      
                        mM.CC.Add(dt_email.Rows[0][1].ToString());
                                             

                        mM.Subject = "Leave Adjustment";

                        mM.Body = get_boy(e.RowIndex, adjust, dt_email.Rows[0][4].ToString(), remarks);

                        mM.IsBodyHtml = true;
                                               
                        SmtpClient SmtpServer = new SmtpClient();

                        SmtpServer.Credentials = new System.Net.NetworkCredential(dt_email.Rows[0][1].ToString(), dt_email.Rows[0][2].ToString());//Provide yoyr gmail credentials email and password

                        SmtpServer.Port = 587;
                       
                        SmtpServer.EnableSsl = true;
                                                
                        SmtpServer.Host = dt_email.Rows[0][3].ToString();

                        SmtpServer.Send(mM);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }


                    MessageBox.Show("Email Notification has been successfully sent.");

如何解决此异常。

I have a windows application desktop-based(C#) developed long days ago by Microsoft Visual Studio 2008. This application used SmtpClient for system-generated email services. smtp.office365.com email service used for from email address. It's working very well but recently shown an exception.

Unable to read data from the transport connection: net_io_connectionclosed.

I am trying to solve it for a few days but not possible.

Code:

  dt_email = dh.select_table("Select * from dbo.tblEmailInfo");
                    try
                    {
                        MailMessage mM = new MailMessage();
                        mM.From = new MailAddress(dt_email.Rows[0][1].ToString());

                        mM.To.Add(this.dgvAction.CurrentRow.Cells[23].Value.ToString());
                      
                        mM.CC.Add(dt_email.Rows[0][1].ToString());
                                             

                        mM.Subject = "Leave Adjustment";

                        mM.Body = get_boy(e.RowIndex, adjust, dt_email.Rows[0][4].ToString(), remarks);

                        mM.IsBodyHtml = true;
                                               
                        SmtpClient SmtpServer = new SmtpClient();

                        SmtpServer.Credentials = new System.Net.NetworkCredential(dt_email.Rows[0][1].ToString(), dt_email.Rows[0][2].ToString());//Provide yoyr gmail credentials email and password

                        SmtpServer.Port = 587;
                       
                        SmtpServer.EnableSsl = true;
                                                
                        SmtpServer.Host = dt_email.Rows[0][3].ToString();

                        SmtpServer.Send(mM);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }


                    MessageBox.Show("Email Notification has been successfully sent.");

How to solve this exception.

enter image description here

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

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

发布评论

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

评论(1

守不住的情 2025-02-09 03:32:18

我遇到了完全相同的问题,您需要将其放在一开始:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12

I've had the exact same issue, you need to put this in the beginning:

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