Home > Blockchain >  MimeKit to read compressed data
MimeKit to read compressed data

Time:08-25

Using MimeKit to read MimeMessage like so:

var message = MimeMessage.Load("C:\\test\\as2\\RawMIMEMsg.txt");
var part = message.BodyParts.FirstOrDefault();

var ms = new MemoryStream();
part.WriteTo(ms);
File.WriteAllBytes("C:\\test\\as2\\MIMEWrittenPart.txt", ms.ToArray());

Where RawMIMEMsg.txt looks like so: enter image description here

I can't figure out how to get decompressed content out of part using MimeKit library. The only method I see is WriteTo but it basically writes this part as is to a file without decompressing it.

CodePudding user response:

Use something like:

 if(message.BodyParts.FirstOrDefault() is ApplicationPkcs7Mime part && part.SecureMimeType==SecureMimeType.CompressedData)
{
    var mimeentity = part.Decompress();
    ...
}

The WriteTo method on the first part is useful to get the data for Mic calculation.

  • Related