Tag: smtpexception

发送电子邮件时发生SmtpException

我试图通过我的C#代码发送电子邮件,但我得到SmtpException 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应173.194.67.109:587 以下是我发送电子邮件的方式: string HostAddress = “smtp.gmail.com”; MailMessage msg = new MailMessage(); msg.From = new MailAddress(fromEmail); msg.Subject = “Test Email”; msg.Body = “Hi testing invoice”; msg.IsBodyHtml = true; msg.To.Add(new MailAddress(“ramshaafaq2012@gmail.com”)); SmtpClient client = new SmtpClient(); client.Host = HostAddress; client.EnableSsl = true; NetworkCredential creadit = new NetworkCredential(); creadit.UserName = msg.From.Address; creadit.Password = Password; client.UseDefaultCredentials = true; […]

System.Net.Mail.SmtpException:系统存储不足。 服务器响应如下:4.3.1系统资源不足

我最近在C#中设计了一个程序,它将从SQL数据库中提取信息,编写带有结果的HTML页面,并自动发送电子邮件。 我一切都在工作[偶尔],我遇到的问题是我似乎正在崩溃我们公司的交换服务器。 在程序的前几次成功运行之后,我将开始获得此exception: 基本exception:System.Net.Mail.SmtpException:系统存储不足。 服务器响应如下:4.3.1系统资源不足 我想知道我是否应该在我的邮件中调用某种类似Dispose()的方法? 或者,如果有任何其他明显的原因导致邮件系统停止响应? 这会影响我们公司的所有客户,而不仅仅是我的代码。 这是Exchange 2010,我的代码是针对.NET 3.5编译的。 我的附件通常是27kb。 如果我登录到Exchange服务器,似乎消息只是无限期地挂在队列中。 清除队列(删除而不发送NDR)并重新启动服务器将重新启动它。 邮件部分如下所示(用户名,密码和地址已更改): public void doFinalEmail() { List distList = new List(); string distListPath = Environment.CurrentDirectory + “\\DistList.txt”; string aLine; logThat(“Attempting email distribution of the generated report.”); if (File.Exists(distListPath)) { FileInfo distFile = new FileInfo(distListPath); StreamReader distReader = distFile.OpenText(); while (!String.IsNullOrEmpty(aLine = distReader.ReadLine())) […]