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

时间:2016-09-12 16:00:42

标签: c# email gmail

我的应用程序已运行了5年,没有任何问题。今天早上,我无法再使用特定的Gmail帐户发送电子邮件。我收到的例外是:无法从传输连接中读取数据:net_io_connectionclosed。使用其他帐户的凭据工作正常。帐户凭据未更改,我可以使用Gmail界面从帐户发送电子邮件。我联系了Google,他们的回复是该帐户看起来不错,它必须是您的应用程序...我的回复,应用程序没有更改并使用其他凭据工作。我的相关代码如下,有什么想法吗?

try
            {
                SmtpClient smtpClient = new SmtpClient();
                using (MailMessage message = new MailMessage())
                {
                    message.From = new MailAddress(Program.EMAIL_SENDER_ADDRESS, "SENDER NAME");
                    message.To.Add(new MailAddress(Program.ERROR_RECIPIENT));

                    message.Subject = callingClass + " ERROR: " + subject;

                    message.IsBodyHtml = true;

                    message.Body = body;

                    smtpClient.Host = "smtp.gmail.com";
                    smtpClient.Port = 587;
                    smtpClient.EnableSsl = true;
                    smtpClient.Credentials = new System.Net.NetworkCredential(Program.EMAIL_SENDER_ADDRESS, Program.EMAIL_SENDER_PASSWORD);

                    smtpClient.Send(message);
                    smtpClient.ServicePoint.CloseConnectionGroup(smtpClient.ServicePoint.ConnectionName);
                }
            }
            catch (Exception x)
            {
                //handle exception
            }

更新 - 在致电Google之后大约30分钟,它神奇地再次开始工作。我想应用程序自行修复了?!?!

1 个答案:

答案 0 :(得分:7)

我前段时间遇到类似的问题。这最终成为解决方案,因为谷歌已经提高了他们的电子邮件应用安全性(截至2016年9月):

使用此Google MyAccount Page

  1. 在Gmail页面中,点击右上角帐户的头像图片。
  2. 按我的帐户。'
  3. 按'登录&安全'
  4. 向下滚动至' Connected Apps&网站'部分。
  5. 切换'允许不太安全的应用'到开。
  6. https://support.google.com/accounts/answer/6010255?hl=en