1

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>
dontknowathing
  • 93
  • 2
  • 11

2 Answers2

0

Check this https://www3.trustwave.com/support/kb/article.aspx?id=11849

  • Navigate to Control Panel.
  • Administrative Tools and then Local Security Policy.
  • Local Policies and Security Options.
  • System Cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing.
  • Disable the setting, and then click Apply.
  • Restart the IIS
komluk
  • 437
  • 4
  • 18
  • I've just tried that, now i'm getting a different error, "Sending email failure" and the inner exception is "The client and server cannot communicate, because they do not possess a common algorithm" – dontknowathing Feb 11 '15 at 16:30
  • I have tried this [link] (http://blogs.msdn.com/b/winsdk/archive/2014/05/01/encountering-quot-the-client-and-server-cannot-communicate-because-they-do-not-possess-a-common-algorithm-quot-or-sec-e-algorithm-mismatch-0x80090331.aspx) but i can't figure out which **cipher** is my server using – dontknowathing Feb 11 '15 at 17:38
0

At the end i just give up with using SmtpClient and MailMessage, i used Outlook MailItem

Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

oMsg.To = "correo@gmail.com";
oMsg.Subject = "Prueba";
oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;

oMsg.HTMLBody = "<html><body>";
oMsg.HTMLBody += string.Format("<p>El dato {0}", var1);
oMsg.HTMLBody += string.Format("se guardo en la  <a href='{0}'>dirección</a>.</p> </br> <p>Saludos.</p> </body></html>", path);

oMsg.Display(false); 
((Microsoft.Office.Interop.Outlook._MailItem)oMsg).Send();
dontknowathing
  • 93
  • 2
  • 11