title: Sending email through proxy using gmail smtp
body: <p>Trying to send some email in my C# app. I am behind a proxy - which is no doubt why the code isn't working. This is what I have so far:</p>
  
  <p><strong>App.Config</strong>:</p>
  
  <pre><code>&lt;system.net&gt;
      &lt;defaultProxy enabled="false"&gt;
        &lt;proxy proxyaddress="xxx.xxx.xxx.xxx"/&gt;
      &lt;/defaultProxy&gt;
      &lt;mailSettings&gt;
        &lt;smtp deliveryMethod="Network"&gt;
          &lt;network host="smtp.gmail.com" port="587"/&gt;
        &lt;/smtp&gt;
      &lt;/mailSettings&gt;
    &lt;/system.net&gt;
  </code></pre>
  
  <p><strong>Code</strong>:</p>
  
  <pre><code>        var username = "...";
          var password = "...";
  
          var fromEmail = "...";
          var toEmail = "...";
          var body = "Test email body";
          var subject = "Test Subject Email";
  
          var client = new SmtpClient("smtp.gmail.com", 587)
          {
              Credentials = new NetworkCredential(username, password),
              EnableSsl = true
          };
  
          try
          {
              client.Send(fromEmail, toEmail, subject, body);
          }
          catch (Exception e)
          {
              MessageBox.Show(e.Message);
          }  
  </code></pre>
  
  <p>Everytime I get System.Net.WebException: The remote name could not be resolved: 'smtp.gmail.com'</p>
  
  <p>Where/how do I start to debug?</p>