Search code examples
c#emailwindows-7exchange-serversmtpclient

5.7.3 Client does not have permission to submit mail to this server on windows 7


I used following code to send E-Mail using exchange server in a win form-application(.net 4 client profile):

public void SendEmail(string From, 
                      string To, 
                      string Subject, 
                      string Body, 
                      string AttachmentFile)
{
   try
   {
      SmtpClient sMail = new SmtpClient("xs1.iasc.net");//exchange or smtp server goes here.
      var SMTPUserInfo = new System.Net.NetworkCredential("user", "pass");

      sMail.UseDefaultCredentials = false;
      sMail.Credentials = SMTPUserInfo;
      sMail.DeliveryMethod = SmtpDeliveryMethod.Network;

      var msg = new MailMessage();
      msg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
      msg.IsBodyHtml = true;
      msg.From = new MailAddress(From);
      msg.To.Add(To);
      msg.Subject = Subject;
      msg.Body = Body;
      sMail.Send(msg);
    }
    catch (Exception ex)
    {
      MessageBox.Show(ex.Message);
    }
}

It works correctly in windows XP but when I run it on Windows 7, I get following error:

Client does not have permission to submit mail to this server. The server response was: 5.7.3 Client does not have permission to submit mail to this server.

Any Idea?


Solution

  • By setting Local Security Setting to Send LM & NTLM -use NTLMv2 session security if negotiated. my problem solved:

    Control Panel>All Control Panel Items>Administrative Tools>Local Security Policy>Security Settings>Local Policies>Security Options>Network Security : LAN Manager Authentication Level

    enter image description here