9

I have a for loop which calls some code sending emails. I get the following run-time error:

Service not available, closing transmission channel. The server response was: 4.4.2 Message submission rate for this client has exceeded the configured limit

After googling around it appears to be related to the "set-receiveconnector", possible for exchange server? Could anyone advise how I can fix this?

the code:

             var mail = new MailMessage();
             var smtpServer = new SmtpClient(SMTPServer);

             mail.From = new MailAddress(fromAddress);
             mail.To.Add(toAddress);
             mail.Subject = title;

             mail.IsBodyHtml = isHTML;
             mail.Body = message;

             if(attach != null) mail.Attachments.Add(attach);

             smtpServer.Port = xxx
             smtpServer.UseDefaultCredentials = false;
             smtpServer.Credentials = new NetworkCredential(SMTPUser, SMTPPassword);
             smtpServer.EnableSsl = true;
             smtpServer.Send(mail); //Error occurs here
intrigued_66
  • 16,082
  • 51
  • 118
  • 189
  • 1
    Given the error, does it not seem more likely this is just a throttling issue on the server to prevent mass spam sendings? You need to slow down your message submission rate. – Adam Wright Jan 27 '12 at 13:22
  • I saw this though: "The message throttling policies doesn't apply to sending mails through SMTP so that can't be the reason." on the MSDN forum from one user? – intrigued_66 Jan 27 '12 at 13:35
  • Can't really answer that (I don't honestly know much about Exchange, hence commenting rather than answering). But the error message seems pretty self explanatory. Perhaps it's IP based throttling? – Adam Wright Jan 27 '12 at 13:37
  • Im actualy only sending 8 emails :s – intrigued_66 Jan 27 '12 at 13:47

3 Answers3

5

Rather then sending the emails directly can you use a pickup folder?

SmtpMail.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;

that way you just dump the messages in to the folder and let exchange send them when its ready, this way if your user can only send say 3 per minute exchange should send 3 then on the next pass send another 3 and so on.

Stuart
  • 1,123
  • 8
  • 24
  • remember you need to set `EnableSsl = false` and also need absolute directory path in `SmtpMail.PickupDirectoryLocation` – mhesabi Feb 10 '15 at 07:33
  • @Sturat, I like this solution. I was able to generate the .eml files. But how exactly can we configure exchange to pickup the mail? – GingerBeer Nov 16 '18 at 05:16
  • @BharatRaj that is way out of scope for SO, had one over to serverfault and they'll sort you out – Stuart Nov 21 '18 at 19:12
1

I resolved this problem on my system by using the correct port. The way exchange had been set up meant that SSL = TRUE, Port = 587 produced this error. If I changed it to use Port 25, then everything worked just fine. So check with your sys admins this may help!

Philip Johnson
  • 1,091
  • 10
  • 24
0

We fixed this from the Exchange side by setting the receive connector(s) to allow more than 5 messages at a time, eg:

Get-ExchangeServer | Set-ReceiveConnector "My Receive Connector" -Messageratelimit 20
KERR
  • 1,312
  • 18
  • 13