Email message RemoveSignature Method not working

Hello there,

I’m processing a signed email using aspose. I tried the msg.RemoveSignature(); method on a message that has property of IsSigned = true, but that property stays the same. How do I get the message IsSigned property to say false so that I can download the message and open it in outlook without error message like “an error occurred in the underlying security system”.

Hello @rusty02,

Can you please provide us with an signed email sample you are using in your test? We will check it on our side and investigate the cause of this problem.

Thanks.

Hello Dmitry,

Attached is a sample sign
test a signed email for K2 ingestion.zip (2.0 MB)

ed email that we are working with. FYI, we ingest this email from outlook then trying to process the email all using Aspose.

Hello @rusty02 ,

Thanks, we will check it and give you a feedback.

Attached is the email created after using aspose to ingest the email in the 1st attachment. This email is the one we cannot open with outlook.
NCATS_PA_3095_Source.zip (1.9 MB)

Hi @rusty02

Please remember that the RemoveSignature method creates a new instance of the unsigned message. See code samples:

            //if you are using MailMessage
            MailMessage eml = MailMessage.Load("test a signed email for K2 ingestion.msg");            
            MailMessage unsignedEml = eml.RemoveSignature();
            bool signed = eml.IsSigned;//true
            signed = unsignedEml.IsSigned;//false
            //if you are using MapiMessage
            MapiMessage msg = MapiMessage.Load("test a signed email for K2 ingestion.msg");
            MapiMessage unsignedMsg = msg.RemoveSignature();
            signed = msg.IsSigned;//true
            signed = unsignedMsg.IsSigned;//false

Please try it and give your feedback.

If you share an example of the code, you are using, we will investigate this issue.

Hello there,
Here is a snippet of the code. We send digitally signed email to a shared mailbox using online exchange, move the email to a folder named “Load to Intake” and use the code to save the signed email to local folder. Opening the saved email gives the error.

NetworkCredential credentials = new OAuthNetworkCredential(accessParameters.UserName, accessToken);
var client = EWSClient.GetEWSClient(exchangeUri, credentials);
ExchangeMailboxInfo exchangeMailboxInfo = client.GetMailboxInfo(sharedMailbox); //sharedemail@domain.com
ExchangeFolderInfoCollection folderInfoCollection = client.ListSubFolders(exchangeMailboxInfo.InboxUri);

                string loadIntakeUri = "";
                string processedUri = "";

                foreach (ExchangeFolderInfo folderInfo in folderInfoCollection)
                {
                    // Call the recursive method to read messages and get sub-folders
                    if (folderInfo.DisplayName == "Load to Intake")
                    {
                        loadIntakeUri = folderInfo.Uri;
                    }
                    else if (folderInfo.DisplayName == "Processed")
                    {
                        processedUri = folderInfo.Uri;
                    }
                }

                ExchangeMessageInfoCollection msgCollection = client.ListMessages(loadIntakeUri, false);
                foreach (ExchangeMessageInfo msgInfo in msgCollection)
                {
                    if (msgInfo.Subject == "test a signed email for K2 ingestion")
                    {
                        String strMessageURI = msgInfo.UniqueUri;
                        Aspose.Email.MailMessage msg = client.FetchMessage(strMessageURI);
                        msg.Save("C:" + "\\" + "Message_out" + timestamp + ".msg", Aspose.Email.SaveOptions.DefaultMsgUnicode);
                    }
                }

Hello @rusty02 ,

Thanks for the details.

@rusty02
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILNET-41205

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @rusty02
We were unable to reproduce this issue in the latest version of the Aspose.Email API. But we noticed that such an error occurred before in older versions. Please try the latest version of Aspose.Email 23.10 and give your feedback.

Hello @alexander.pavlov ,
I have tried updating to the lastest ASPOSE.Email version 23.10 and I’m still having the same issue. Have you tried the code I pasted?

Hello @rusty02,

We’ll review this again and write back to you later.

Any update on this?

Hello @rusty02,

Your ticket is still under investigation.
Thank you for patience and sorry for the inconvenience.

Hi @rusty02
We’ve uploaded your signed message file to our server and ran your example code to receive the message. If we used Aspose.Email dll version 23.5 (and earlier) we get the same error, but since Aspose.Email dll version 23.6 (and later) this bug has been fixed and there are no errors. Both result files are attached here. Also, when analyzed using SSView, it is clear that the structure of the file obtained using version 23.5 differs from the original one, and starting from version 23.6 it is the same as the original one (see screenshots).
So, we see that this error has been fixed and we ask you to double-check which version of Aspose.Email you were using.
test a signed email for K2 ingestion.msg_saved_AE_23_5.zip (1.9 MB)

test a signed email for K2 ingestion.msg_saved_AE_23_6.zip (2.0 MB)

source.jpg (173.6 KB)

AE23_5.jpg (179.0 KB)

AE23_6.jpg (178.6 KB)

Hello @alexander.pavlov ,
I tried using Apose.Email.dll version 23.6 and 23.10 both gave me the same result with a message i can’t open (see attachment). I’ve attached the sourcecode and the email it generated. Please review and let me know what I should try next.

Program.zip (931 Bytes)
messageGenerated.zip (1.9 MB)

Hello @rusty02 ,

Thanks for the details provided.
We will check it.

@dmitry.samodurov any update on this issue ?

Hi @rusty02
In your first post you provided the code

                        Aspose.Email.MailMessage msg = client.FetchMessage(strMessageURI);
                        msg.Save("C:" + "\\" + "Message_out" + timestamp + ".msg", Aspose.Email.SaveOptions.DefaultMsgUnicode);

which confused us and we couldn’t find the problem in the latest version.
In your last post you sent to us more complete code

                    Aspose.Email.MailMessage msg = client.FetchMessage(strMessageURI);
                    if (msg.IsSigned)
                    {
                        msg = msg.RemoveSignature();
                    }
                    // Save the email msg file to the File folder
                    msg.Save("C:\\test" + "\\" + "Message_" + (count) + "_out" + ".msg", Aspose.Email.SaveOptions.DefaultMsgUnicode);

and we were able to reproduce the problem. The issue has been fixed and a fix will be available in an upcoming release.