I am trying to automate an email in C# asp.net 4.0 project with an exchange server and I am receiving the error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated.
The system administrator has assured me that there is no credentials set up so I am using the default credentials. I have set up my code as followed.
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("exchange.XXX.lan", 25);
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage("Foo@XXX.com",
"Foo@XXX.com",
"test",
"TEST!");
client.UseDefaultCredentials = true;
client.EnableSsl = true;
client.Send(msg);
And my Configuration file as:
<system.net>
<mailSettings>
<smtp from="helpdesk@XXX.com">
<network host="exchange.XXX.lan" port="25" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>