title: c# send email trough other host than gmail
body: <p>I'm currently developing an app with c# and I want to send an email from a smtp host called '<strong>smtp.online.nl</strong>'. I'm using port <strong>485</strong> (as I saw on their tutorial how to configure a mail client) and everything seems to be correct.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>        MailMessage message = new MailMessage();
          message.To.Add("testEmail@hotmail.com");
          message.Subject = "C# generated message!";
          message.From = new MailAddress("mySendemailAddress@online.nl");
          message.Body = "This is the message body \r\nThis is a next line";
          message.DeliveryNotificationOptions=DeliveryNotificationOptions.OnFailure;
          SmtpClient smtp = new SmtpClient("smtp.online.nl", 485);
          smtp.EnableSsl = true;
          smtp.UseDefaultCredentials = false;
          smtp.Credentials=new NetworkCredential("mySendEmailAddress@online.nl", "password");
  
          smtp.Send(message);
  </code></pre>
  
  <p>When I run this, the email won't be send and I got a <code>SmtpException: "Error sending e-mail".</code></p>
  
  <p>My question: is there anything wrong with my code? Any other idea's why I'm getting this error?</p>