title: How to send email through SMTP protocol using CSharp and proxy network?
body: <p>I am working in a project , In which i will be retrieving the password of the user from the database and mail it to the user email id. For this i am using SMTP protocol. But i was not able to send the mail from my application.
  I am using proxy network in the company in which i am working.
  I think using proxy network is the reason for getting error while sending the email.
  Is there any alternate solution for sending the email through SMTP protocol from a proxy network.</p>
  
  <p><strong>code used.</strong></p>
  
  <pre><code>    MailMessage mm = new MailMessage("sender@gmail.com", txtEmail.Text.Trim());
          mm.Subject = "Password Recovery";
          mm.Body = string.Format("Hi {0},&lt;br /&gt;&lt;br /&gt;Your password is {1}.&lt;br /&gt;&lt;br /&gt;Thank You.", username, password);
          mm.IsBodyHtml = true;
          SmtpClient smtp = new SmtpClient();
          smtp.Host = "smtp.gmail.com";
          smtp.EnableSsl = true;
          NetworkCredential NetworkCred = new NetworkCredential();
          NetworkCred.UserName = "sender@gmail.com";
          NetworkCred.Password = "senderpassword";
          smtp.UseDefaultCredentials = true;
          smtp.Credentials = NetworkCred;
          smtp.Port = 587;
          smtp.Send(mm);
          lblMessage.ForeColor = Color.Green;
          lblMessage.Text = "Password has been sent to your email address.";
  </code></pre>
  
  <p><strong>Exception image:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/vmTZH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vmTZH.png" alt="Exception:"></a></p>