Free Support Forum -

DKIM failed using Aspose.Email

Hi Aspose Team ,
I am using 19.8 latest version .If i use only plain text then dkim passed but when we use html body then it gives an error dkim fail with message dkim=fail(body hash did not verify).
i have enable same MailMessage.IsBodyHtml = true;
please suggest .


Can you please share source file along with sample code so that we may further investigate to help you out.

MailMessage MailMessage = new MailMessage();

        #region Sender (作為主要退信address)
        MailMessage.Sender = "";
        MailMessage.Sender.DisplayName = "達璟資訊 Dajinsoft";

        #region From
        MailMessage.From = "";
        MailMessage.From.DisplayName = "達璟資訊";

        #region To

        #region Content
        MailMessage.Subject = "諮詢回覆通知ABC";
        StringBuilder sb = new StringBuilder();
        StreamReader sr = new StreamReader(@"C:\EMAIL_DEMO.html", Encoding.UTF8);
        MailMessage.HtmlBody = sb.ToString();
        MailMessage.IsBodyHtml = true;

        MailMessage.BodyEncoding = Encoding.UTF8;
        MailMessage.SubjectEncoding = Encoding.UTF8;
        MailMessage.PreferredTextEncoding = Encoding.UTF8;

        MailMessage = SignedDKIM(MailMessage);
        //MailMessage.Save(FilePath, SaveOptions.DefaultEml);

        SmtpClient client = new SmtpClient();
        client.Host = "";
        client.Username = "username";
        client.Password = "password";
        client.Port = 25;
        //client.UseAuthentication = false;
        //client.SupportedEncryption = Aspose.Email.Clients.Base.EncryptionProtocols.Ssl2;
        client.SecurityOptions = SecurityOptions.None;
    catch (Exception)

private MailMessage SignedDKIM(MailMessage mailMessage)
    string privateKeyFile = @"C:\Develop\Dajin\Product\CRM\CommonFiles\Settings\Email.Key.pem";

    //加密演算法, 預設為 rsa
    RSACryptoServiceProvider rsa = PemReader.GetPrivateKey(privateKeyFile);

    string selector = "s1233225";
    string domain = "";
    DKIMSignatureInfo signInfo = new DKIMSignatureInfo(selector, domain);
    signInfo.HashAlgorithm = DKIMHashAlgorithm.RSASha256;
    signInfo.BodyCanonicalization = CanonicalizationType.Relaxed;
    signInfo.HeaderCanonicalization = CanonicalizationType.Relaxed;

    MailMessage signedMsg = mailMessage.DKIMSign(rsa, signInfo);

    return signedMsg;

We are using same code from your portal-Email DKIM


The thread that you have referred has been fixed in Aspose.Email for .NET 19.8. As you have shared that you are still able to reproduce the issue. I request you to please share the working sample project along with source HTML file and test account that we may try on our end to verify and resolve the issue. (3.4 MB)
Please find zip file as source code.


Thank you for sharing the sample project. I have tried using that on my end and getting exception on getting private key file as shown in Figure below. As requested earlier, can you please provide a working sample project along with test account access that is reproducing the issue on your end.

I have also observed your in project that you have been using Aspose.Email for .NET 19.3. Whereas, I suggested you to please use Aspose.Email for .NET 19.8 on your end.

image.png (21.7 KB)

As I seen that i am using latest version 19.8 of Aspose.Email.Some security reason I can’t provide you private key.Can you please test the scenario.


I have created an issue with ID EMAILNET-39571 as investigation to further investigate the issue on our end. We will share feedback with you as soon as the issue will be fixed.


I am looking for solution for this issue.we did not receive any feedback from your side.
Please help us for the solution ASAP.



I have observed your comments and like to share that the issue has just recently been added in our issue tracking system and is pending for investigation in issues queue. We request for your patience till the time the issue gets scheduled on its due turn and feedback is shared.

Hi Aspose Team,

As I seeing EMAILNET-39571 is resolved.Is it released or not?
If released then what is change in code. Please suggest me.

Issues Status

EMAILNET-39571 ---- Status : Resolved



I like to inform that this issue has been resolved in 19.9 which will be release soon.

1 Like

can you please tell expected date by when this will be release?


I request you to please try using latest Aspose.Email for .NET version on your end and share your feedback if there is still an issue.

hey !
this is Aspose Slides for .NET 19.9 link not for email.
please provide us to Aspose.Email for .Net link


I like to inform that Aspose.Email 19.8 will be available before the end of September. I request for your patience.

Thanks for your response.

Hi Aspose Team,

Is this release can you confirm verifying signature with Attachments and cc’d will work fine ?


Yes, this issue will be resolved in 19.9. We will share good news with you soon. I request for your patience.