title: C# windows service sending mail - client was not authenticated
body: <p>I've got a windows service that sends mails to users. The code that is used, is the basic way for sending mail.</p>
  
  <pre><code>SmtpClient client = new SmtpClient("servername");
  MailMessage msg = new Mailmsg(); ...// configuration
  client.send(msg);
  </code></pre>
  
  <p>If I set the credentials from client , i can send a mail through the Exchange server (2007). The exchange server is configured to allow to send emails without authentication(anonymously).</p>
  
  <p>So if I dont provide credentials with usedefaultcredentials on false, it works in my console application, but not in my windows service.</p>
  
  <p>I get the message "the smtp server requires a secure connection or the client was not authenticated".
   Anyone an idea why I get this when I use a windows service , instead of a console app (identical code)</p>