ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
308 stars 76 forks source link

Msg file corrupt #95

Closed nylu closed 1 year ago

nylu commented 1 year ago

When loading an .msg Outlook E-Mail and just saving it again, the saved .msg file seems to be corrupt. When opening this file in Outlook you only get a nonsense error message:

We can't open 'C:\Path\To\Email.msg'. It's possible the file is already open, or you don't have permission to open it.

The code i'm using:

var cf = new CompoundFile(@"C:\Path\To\Email.msg");
cf.Save(@"C:\Path\To\corrupt.msg");

The file size is identical but the content differs. What is going wrong here? What do i have to do so that outlook accepts the files created by this library?

ironfede commented 1 year ago

Hi @nylu , I'm trying to replicate issue but I cannot reproduce it since the saved .msg file is being correcly opened by Outlook. I'm not expecting the same contents in the file since stucture of directory is recreated on saving file and some "structural" data can be different even if semantically equivalent. Are you sure you are correctly closing the target file after you've saved it? It looks like a lock problem on msg file still opened by your openmcdf application. Please let me know and in case, if you prefer, put an example "original" msg file obviously without sensitive information in it in order to check this problem. Best Regards, Federico

ironfede commented 1 year ago

Here's my testing code...

 [TestMethod]
public void Test_Issue95_MSG()
{
    var f = new CompoundFile("Prova.msg");
    f.Save("Prova2.msg");
    f.Close();
}
ironfede commented 1 year ago

Closing as non-replicable. Please @nylu , if you have more detailed info open a new issue. Thank you