title: Asp.net sending email
body: <p>How can I send an activation email when new users register in my website using asp.net c#? I have tried the steps described
  <a href="http://www.aspsnippets.com/Articles/Send-user-Confirmation-email-after-Registration-with-Activation-Link-in-ASPNet.aspx" rel="nofollow noreferrer">this link</a> but I have faced this error:</p>
  <blockquote>
  <p>System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.</p>
  </blockquote>
  <p>Is there any solution to this or any other way to send an email?</p>
  <p>this is my code</p>
  <pre><code>using (MailMessage mm = new MailMessage(&quot;sender@gmail.com&quot;, txtEmail.Text))
  {
      mm.Subject = &quot;Account Activation&quot;;
      string body = &quot;Hello &quot; + txtUsername.Text.Trim() + &quot;,&quot;;
      body += &quot;&lt;br /&gt;&lt;br /&gt;Please click the following link to activate your account&quot;;
      body += &quot;&lt;br /&gt;&lt;a href = '&quot; + Request.Url.AbsoluteUri.Replace(&quot;CS.aspx&quot;, &quot;CS_Activation.aspx?ActivationCode=&quot; + activationCode) + &quot;'&gt;Click here to activate your account.&lt;/a&gt;&quot;;
      body += &quot;&lt;br /&gt;&lt;br /&gt;Thanks&quot;;
      mm.Body = body;
      mm.IsBodyHtml = true;
      SmtpClient smtp = new SmtpClient();
      smtp.Host = &quot;smtp.gmail.com&quot;;
      smtp.EnableSsl = true;
      NetworkCredential NetworkCred = new NetworkCredential(&quot;sender@gmail.com&quot;, &quot;&lt;password&gt;&quot;);
      smtp.UseDefaultCredentials = true;
      smtp.Credentials = NetworkCred;
      smtp.Port = 587;
      smtp.Send(mm);
  }   
  </code></pre>
  <p>The proposed duplicate did not solve the problem. I am already using port 587.</p>