System.Net.Mail.SmtpException:没有足够的系统存储空间。服务器响应为:4.3.1系统资源不足 [英] System.Net.Mail.SmtpException: Insufficient system storage. The server response was: 4.3.1 Insufficient system resources

查看:6256
本文介绍了System.Net.Mail.SmtpException:没有足够的系统存储空间。服务器响应为:4.3.1系统资源不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近设计在C#程序,将拉动信息从SQL数据库,对结果编写一个HTML页面,并自动通过电子邮件发送出去。我就拥有了一切工作[零星],我遇到的问题是,我似乎崩溃我们公司的Exchange服务器。该计划的前几个成功运行后,我会开始得到此异常:




基本异常:System.Net.Mail.SmtpException :没有足够的系统存储空间。服务器响应为:4.3.1系统资源不足




我想知道如果我要调用某种处置() - 就像在我的邮件的方法?或者,如果有任何其他明显原因,我将导致邮件系统停止响应?这会影响到所有的客户在我们公司,不只是我的代码。



这是Exchange 2010中,我的代码是针对.NET 3.5编译。我的附件通常是27KB。如果我登录到Exchange服务器,似乎消息只是坚持在队列无限期。清理出队列(删除不发送NDR),并重启服务器会再次去。



邮件的部分看起来像这样(用户名,密码和地址变更)

 公共无效doFinalEmail()
{
名单,LT;字符串> distList =新的List<串GT;();
串distListPath = Environment.CurrentDirectory +\\DistList.txt
串阿利娜;

logThat(试图生成的报告的电子邮件分发。);

如果(File.Exists(distListPath))
{
FileInfo的源码包=新的FileInfo(distListPath);
StreamReader的distReader = distFile.OpenText();

,而(String.IsNullOrEmpty(艾琳= distReader.ReadLine())!)
{
distList.Add(艾琳);
}
}
,否则
{
logThat([[错误]:分发列表不存在路径:+ distListPath);
}

味精MAILMESSAGE新= MAILMESSAGE();
MailAddress FROMADDRESS =新的MailAddress(emailaddresshere);
msg.From = FROMADDRESS;

logThat(收件人:);
的foreach(在distList串anAddr)
{
msg.To.Add(anAddr);
logThat(\t+ anAddr);
}
如果(File.Exists(Program.fullExportPath))
{
logThat(附:+ Program.fullExportPath);
扣押mailAttachment =新的附件(Program.fullExportPath);
msg.Attachments.Add(mailAttachment);
串SUBJ =公司+ Program.yestFileName;
msg.Subject = SUBJ;
msg.IsBodyHtml = TRUE;
msg.BodyEncoding = System.Text.Encoding.UTF8;
的sendmail(MSG);
}
,否则
{
logThat([[错误]:附件不存在路径:+ Program.fullExportPath);
}
}

公共无效的sendmail(MAILMESSAGE MSG)
{

{
字符串的用户名=用户 ; //域用户
字符串密码=通行证; //密码
SmtpClient mClient =新SmtpClient();
mClient.Host =192.168.254.11;
mClient.Credentials =新的NetworkCredential(用户名,密码);
mClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mClient.Send(MSG);
}
赶上(例外哎呀)
{
串whatHappened =的String.Format(本公司:\r\\\
Failure在{0} \r\\\
! \r\\\
Error消息:{1} \r\\\
Error数据:{2} \r\\\
\r\\\
Stack跟踪:{3} \r\\\
\r\ n基准异常:{4}在方法\r\\\
Occuring:{5},类型为{6} \r\\\
的,oops.Source,oops.Message,oops.Data,oops.StackTrace,哎呀.GetBaseException(),oops.TargetSite,oops.GetType());
logThat(whatHappened);
Environment.Exit(1);
}
}


解决方案

这可能发生错误时:




  1. Exchange服务器的磁盘空间不足

  2. 收件人邮箱。是的磁盘空间。



这是较常见比问题#1碰上问题#2。



下面是交换状态代码列表及其含义。


I've recently designed a program in C# that will pull information from SQL databases, write an HTML page with the results, and auto-email it out. I've got everything working [sporadically], the problem I'm having is that I seem to be crashing our company's exchange server. After the first few successful runs of the program, I'll start getting this exception:

Base exception: System.Net.Mail.SmtpException: Insufficient system storage. The server response was: 4.3.1 Insufficient system resources

I'm wondering if I should be calling some sort of Dispose()-like method in my mailing? Or if there is any other apparent reason that I would be causing the mail system to stop responding? This affects all clients in our company, not just my code.

This is Exchange 2010, and my code is compiled against .NET 3.5. My attachments are typically 27kb. If I log into the exchange server, it seems that messages just stick in a queue indefinitely. Clearing out the queue (remove without sending NDR) and rebooting the server will get it going again.

The mailing portions look like this (username, password, and address changed):

public void doFinalEmail()
{
     List<string> distList = new List<string>();
     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()))
         {
             distList.Add(aLine);
         }
     }
     else
     {
         logThat("[[ERROR]]: Distribution List DOES NOT EXIST! Path: " + distListPath);
     }

     MailMessage msg = new MailMessage();
     MailAddress fromAddress = new MailAddress("emailaddresshere");
     msg.From = fromAddress;

     logThat("Recipients: ");
     foreach (string anAddr in distList)
     {
         msg.To.Add(anAddr);
         logThat("\t" + anAddr);
     }
     if (File.Exists(Program.fullExportPath))
     {
         logThat("Attachment: " + Program.fullExportPath);
         Attachment mailAttachment = new Attachment(Program.fullExportPath);
         msg.Attachments.Add(mailAttachment);
         string subj = "Company: " + Program.yestFileName;
         msg.Subject = subj;
         msg.IsBodyHtml = true;
         msg.BodyEncoding = System.Text.Encoding.UTF8;
         sendMail(msg);
     }
     else
     {
         logThat("[[ERROR]]: ATTACHMENT DOES NOT EXIST! Path: " + Program.fullExportPath);
     }
 }

 public void sendMail(MailMessage msg)
 {
     try
     {
         string username = "user"; //domain user
         string password = "pass"; // password
         SmtpClient mClient = new SmtpClient();
         mClient.Host = "192.168.254.11";
         mClient.Credentials = new NetworkCredential(username, password);
         mClient.DeliveryMethod = SmtpDeliveryMethod.Network;
         mClient.Send(msg);
     }
     catch (Exception oops)
     {
         string whatHappened = String.Format("Company: \r\nFailure in {0}! \r\n\r\nError message: {1} \r\nError data: {2} \r\n\r\nStack trace: {3} \r\n\r\nBase exception: {4} \r\nOccuring in method: {5} with a type of {6}\r\n", oops.Source, oops.Message, oops.Data, oops.StackTrace, oops.GetBaseException(), oops.TargetSite, oops.GetType());
         logThat(whatHappened);
         Environment.Exit(1);
     }
 }

解决方案

This error can happen when:

  1. The exchange server is out of disk space.
  2. The recipient mailbox is out of disk space.

It is more common to run into issue #2 than issue #1.

Here is a list of Exchange Status Codes and their meanings.

这篇关于System.Net.Mail.SmtpException:没有足够的系统存储空间。服务器响应为:4.3.1系统资源不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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