title: SMTP mail sending in C# (internet connection + WebProxy)
body: <p>The goal is to send an email from a C# application. The code snippet below works for me, but when I run it at work (internet connection with a script configuration proxi.pac) it crashes.</p>
  
  <p>Can someone help me?</p>
  
  <pre><code>string SendersAddress = "jd@gmail.com";
  string ReceiversAddress = "dj@xxx.com";
  
  const string SendersPassword = "xxxxxx";
  const string subject = "Testing Gmail LOCAL";
  const string body = "Hi This Is my Mail From Gmail";
  
  try
  {
    SmtpClient smtp = new SmtpClient
    {
      Host = "smtp.gmail.com",
      Port = 587,
      EnableSsl = true,
      DeliveryMethod = SmtpDeliveryMethod.Network,
      Credentials = new NetworkCredential(SendersAddress, SendersPassword),
      //Timeout = 3000
    };
  
    MailMessage message = new MailMessage(SendersAddress, ReceiversAddress, subject, body);
    smtp.Send(message);
    Console.WriteLine("Message Sent Successfully");
    Console.ReadKey();
  }
  </code></pre>