0

I have a winforms app that sends email with code below:

MailMessage mail = new MailMessage();
mail.To.Add(textBox1.Text);
mail.Priority = MailPriority.High;
mail.From = new MailAddress("autoemailer@no-reply", "Auto Email");
mail.Subject = "Test Email";
mail.Body = "Kindly disregard if received";

SmtpClient smtp = new SmtpClient();
smtp.Host = "172.16.224.7";
smtp.Port = 25; //587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
    ("username", "password"); // Sender's user name and password. Note: The username and password here is an example. Real username and password are the same as outlook's

try
{
    smtp.Send(mail);
    MessageBox.Show("Sent!");
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

I'm getting the following exception:

Insufficient system storage. The server response was: 4.3.1 Insufficient system resources

The exception message was clear that the server is low on storage/resources. But when I tried sending email thru Outlook, it sent successfully. Is there something wrong with the code? TIA for any help.

benPearce
  • 37,735
  • 14
  • 62
  • 96
exile0228
  • 1
  • 2
  • Same credentials in the code and Outlook? – Loathing Sep 09 '15 at 02:24
  • This can happen when either the exchange server is out of disk space or the recipient mailbox is out of disk space. – thewisegod Sep 09 '15 at 02:25
  • It also happens when the recipient mailbox is out of space. Was it the same in both of your tests? – Phil-R Sep 09 '15 at 02:26
  • @Loathing Yes.. in terms of the real username and password. The username and password I posted here are samples. I'll just edit my comments on that line so as not to confuse everyone. – exile0228 Sep 09 '15 at 02:38
  • @Phil-R In both my tests, I sent email to my outlook. The first one, I used my program and the exception occurred. The second one, I used outlook itself, the email was sent and I received it. My mailbox surely is not out of space. – exile0228 Sep 09 '15 at 02:40
  • I don't think your error is caused by it, but your sender's email address is invalid (autoemailer@no-reply => autoemailer@no-reply.com). Any results with it changed? – Phil-R Sep 09 '15 at 02:43
  • Is Outlook using `SSL` and a certificate? – Loathing Sep 09 '15 at 02:47
  • http://stackoverflow.com/questions/14692376/system-net-mail-smtpexception-insufficient-system-storage-the-server-response – benPearce Sep 09 '15 at 02:51
  • @Phil-R It didn't work. The email address is actually used for impersonation and one of my colleagues is using this technique. As long as the credential is valid, he said it will work. But I also tried changing the email address to the real one that's sending the email and it worked. Now I'm wondering why the impersonation failed :)) Anyways, thanks for the help. – exile0228 Sep 09 '15 at 03:01

0 Answers0