title: net.mail and web.mail vs gmail
body: <p>I am wondering, if I can use <code>System.Net.Mail</code> with 465 port and <code>System.Web.Mail</code> with 587 port. For example for gmail, I cannot switch ports in this example as it will throw transport protocol exception...</p>
  
  <pre><code>using web = System.Web.Mail;
  using net = System.Net.Mail;
  
  private void SendMail()
  {
      web.MailMessage webMail = new web.MailMessage();
      webMail.To = "MAILTO@gmail.com";
      webMail.From = "MAILFROM@gmail.com";
  
      webMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
      webMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");            
      webMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
      webMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "LOGIN");
      webMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "PASSWORD");
      webMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);
      web.SmtpMail.SmtpServer = "smtp.gmail.com";
      web.SmtpMail.Send(webMail);
  
      net.SmtpClient smtp = new net.SmtpClient();
      smtp.UseDefaultCredentials = false;
      smtp.Credentials = new System.Net.NetworkCredential("LOGIN", "PASSWORD");
      smtp.Port = 587;
      smtp.Host = "smtp.gmail.com";
      smtp.EnableSsl = true;
  
      var netMail = new net.MailMessage(new net.MailAddress("MAILFROM@gmail.com", "", System.Text.Encoding.UTF8),
                                        new net.MailAddress("MAILTO@gmail.com", "", System.Text.Encoding.UTF8));
  
      smtp.Send(netMail); 
  }
  </code></pre>
  
  <p>I am asking because even the simplest second <code>Net.Mail</code> cannot be sent under Russian Win 7 64x in .Net 2.0 build - it throws exception about invalid character in the header... And We.Mail works as expected. But I dont want to use it...</p>