I'm trying to send an email via my C# application, but every time i try to send the email, an error occurs, saying "A call to sspi failed", when i look at the inner exeption it says something like "The client and server cannot communicate, because they do not possess a common algorithm"
My code is this:
try
{
var fromAddress = new MailAddress("sender@domain.com", "Sender");
var toAddress = new MailAddress("receiver@domain.com", "Receiver");
const string fromPassword = "Pass123";
const string subject = "Prueba";
const string body = "Prueba body";
var smtp = new SmtpClient
{
Host = "smpt.domain.com",
Port = 25,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body,
DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure,
BodyEncoding = UTF8Encoding.UTF8
})
{
smtp.Send(message);
}
}
catch (Exception exc)
{
MessageBox.Show(string.Format("Error: {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
And on my App.config i have something like:
<system.net>
<mailSettings>
<smtp from="sender@domain.com">
<network host="smtp.domain.com" port="25" userName="sender@domain.com" password="Pass123" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>