Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TnefPart.ConvertToMessage() adds unnecessary Multipart MimeEntity for signed TNEF Messages with an encoded body. #789

Closed
Schumacher-Bastian opened this issue Apr 27, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@Schumacher-Bastian
Copy link

Schumacher-Bastian commented Apr 27, 2022

Describe the bug
TnefPart.ConvertToMessage() adds unnecessary Multipart MimeEntity for signed TNEF Messages with an encoded body. This Multipart then contains only one child. This is new since MimeKit 3.2 and causes that Outlook no longer properly displays the message.

Platform (please complete the following information):

  • OS: Windows 11
  • .NET Runtime: CoreCLR
  • .NET Framework: [.NET 4.8.2, .NET 5.0]
  • MimeKit Version: 3.2

To Reproduce
Steps to reproduce the behavior:

  1. Download and extract the attached "NoContentAfterTnefToMimeConversion.zip"
  2. Open the extracted "NoContentAfterTnefToMimeConversion.sln"
  3. Build and Exeute the contained "MimeKit_3_2" project
  4. Open the "TnefPartConvertedToMessage.eml" that has been generated in outlook

Expected behavior
The content of the mail is Displayed and the mail is marked as a signed mail.

Code Snippets
If applicable, add code snippets to help explain your problem.

    class Program
    {
        static void Main(string[] args)
        {
            using var message = ParseMessage("SignedTnefMailWithEncodedBody.eml");
            using var tnefPart = (TnefPart) message.BodyParts.First(x => x is TnefPart);
            var convertedTnefPart = tnefPart.ConvertToMessage();

            SaveMessage(convertedTnefPart, "TnefPartConvertedToMessage.eml");
        }

        private static void SaveMessage(MimeMessage convertedTnefPart, string fileName)
        {
            using var tnefPartConvertedToMessage = File.OpenWrite(fileName);
            convertedTnefPart.WriteTo(FormatOptions.Default, tnefPartConvertedToMessage);
        }

        private static MimeMessage ParseMessage(string fileName)
        {
            using var signedTnefMailWithEncodedBody = File.OpenRead(fileName);
            var mimeParser = new MimeParser(signedTnefMailWithEncodedBody);
            return mimeParser.ParseMessage();
        }
    }

Additional context
I have attached a solution to demonstrate the issue: "NoContentAfterTnefToMimeConversion.zip"
The solution contains a project that uses MimeKit 3.1.1 which works as expected and one that uses MimeKit 3.2 which shows the problem.
NoContentAfterTnefToMimeConversion.zip

The following screenshot shows how it looks with MimeKit 3.2
2022-04-27 13_38_28-signed encoded tnef - MimeKit 3 2

The following screenshot shows how it should look like in Outlook (MimeKit 3.1.1)
2022-04-27 13_38_28-signed encoded tnef - MimeKit 3 1 1

The following screenshot shows the difference of the EML files that are generated by MimeKit 3.1.1 and 3.2.
2022-04-27 13_43_51-WinMerge -  TnefPartConvertedToMessage eml x 2

@jstedfast jstedfast added the bug Something isn't working label Apr 27, 2022
jstedfast added a commit that referenced this issue May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants