SendGrid SMTP error {"Unable to read data from the transport connection: net_io_connectionclosed."}
<p>This might seem to be duplicate but it is not. I tried restarting the IIS, enclosing the SMTPClient in the using block etc. But Still I'm getting the error. </p>

<pre><code>try
{
   //I have replaced sender@gmail.com and receiver@gmail.com by a valid gmail addresses
    MailAddress sender = new MailAddress("sender@gmail.com");
    MailAddress receiver = new MailAddress("receiver@gmail.com");
    MailMessage mailMsg = new MailMessage(sender, receiver);
    mailMsg.Subject = "subject";

    string text = "text body";
    string html = @"&lt;p&gt;html body&lt;/p&gt;";

    mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(text,  null, MediaTypeNames.Text.Plain));
    mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));


    using(SmtpClient smtpClient = new SmtpClient())
        {
           smtpClient.Host = "smtp.sendgrid.net";
           smtpClient.Port = 587;
           smtpClient.EnableSsl = true;

          //UserName = Username of SendGrid account, Password = Password of SendGrid account
           System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("UserName", "password");
           smtpClient.Credentials = credentials;
           smtpClient.ServicePoint.MaxIdleTime = 1; /* without this the connection is idle too long and not terminated, times out at the server and gives sequencing errors */

           smtpClient.Send(mailMsg);            

         }            
}
catch (SmtpException ex)
     {
         Console.WriteLine(ex.Message);
     }

catch (Exception ex)
     {
          Console.WriteLine(ex.Message);
     }
</code></pre>

<p>This is a MVC application developed in VS 2015. </p>

<p>Any input on this will be helpful.</p>