System.Net.Mail.SmtpException: insufficient system storage. Server response: 4.3.1 Not enough system resources

I recently developed a C # program that will extract information from SQL databases, write an HTML page with the results, and automatically send it by email. Everything works for me [sporadically], the problem that I am facing is that I seem to be breaking the exchange server of our company. After the first few successful launches of the program, I will begin to receive this exception:

Basic exception: System.Net.Mail.SmtpException: insufficient system storage. Server response: 4.3.1 Not enough system resources

I am wondering if I should call some Dispose () method in my newsletter? Or, if there is some other obvious reason why I will force the mail system to stop responding? This applies to all customers in our company, not just my code.

This is Exchange 2010, and my code is compiled with .NET 3.5. My attachments are usually 27kb. If I log into the exchange server, it seems that the messages just remain in the queue for an indefinite period. Clearing the queue (deleting without sending NDR) and restarting the server will start again.

The mailing parts are as follows (username, password and address are 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); } } 
+4
source share
3 answers

This error may occur if:

  • The exchange server does not have disk space.
  • Recipient's mailbox does not have disk space.

Most often, problem number 2 arises than problem number 1.

Here is a list of Exchange status codes and their meanings.

+4
source

To narrow down the problem completely, you can exchange another email client, such as aspNetEmail (you can get a test version for verification), it will not take just a few lines of code. If the problem persists, it is on the server; if not, then it is on the client. I would strongly suspect that this is a problem on the server, however, since when the client closes the connection and a message is sent, the server should really not contain any resources as a result of this connection. You can verify this by looking at your SMTP logs and making sure that there were no SMTP errors when closing the connection.

If this is really a problem on the server (the SMTP log shows a clean shutdown and the problem is replicated using an alternative client), then I would go to the server (if you can access) and look at the disk space as jeuton suggests.

+2
source

In 2007, c: (system disk) required about 4 GB of free disk space. That was our problem. Disk increment and mail will flow again.

0
source

All Articles