EML to TIFF conversion header length issue in C# .NET

Hello,

We are using GroupDocs.Conversion .NET library version 18.4.0. We are having major problems with eml->tiff conversion due to a bug (?) in the library.

We noticed that the converter only allows max 512 character per row even though there are no such limitations in the rfc822 standard. Files with longer header rows are converted to images of the raw contents of the eml files.

How could we get rid of this kind of behaviour?

Another thing that we noticed is that conversion tiff->tiff does not seem to work properly and produces scrambled images. Even though the image format doesn’t need to be changed in this case, we would like to run also tiff images through the conversion to adjust the image settings (resolution etc.) consistently with other file formats. Any change to get this fixed?

@jauho,

Thank you for your inquiry.

We investigated this issue at our end. The output file (Tiff) shows less characters in a row as compare to length of a row in email file. However, we don’t find it restricted to 512 characters only. Maybe its because we have a different sample file. So, in order to further investigate this issue, we need the problematic (.eml) file form you.

We can do this conversion without any issue using a sample Tiff file. Please share the problematic file with us. So, that we could further examine it.

This scenario is under investigation and logged in our internal issue tracking system with ID:CONVERSIONNET-2507. As we have any update on this, we shall notify you.

I have attached a simplified example of such eml file and conversion result (‘Test_LongHeader.eml’ & ‘Test_LongHeader.tif’). In this example the subject header row is 513 character long and the conversion result is invalid. In another, almost identical file the subject header row is 512 character long and the conversion result is valid (see attached files ‘Test_Ok.eml’ & ‘Test_Ok.tif’). We see this behaviour also with other headers, not only with the subject header.

Note that if we used the ‘folding’ technique to shorten the row, the conversion result would be fine. However, there are cases where we cannot use folding because there are no whitespace character in the header contents (headers with encoded/structured data, for example x-forefront-antispam-report & x-microsoft-exchange-diagnostics). See files ‘Test_LongHeaderFolded.eml’ & ‘Test_LongHeaderFolded.tif’ for conversion with a folded header row.

TestFiles.zip (100.4 KB)

@jauho,

Thank you for sharing the problematic files. We converted those files into tif and the output of Test_LongHeader.eml is different at our end.
Please go through these output files - ConvertedFiles.zip (18.3 KB)

We are using following code for this particular conversion process:

        // Instantiating the conversion handler from custom common class
        ConversionHandler conversionHandler = Common.getConversionHandler(); ;

        // Convert and save converted image file.
        // Returns paths to the converted image file.
        var saveOptions = new ImageSaveOptions
        {
            ConvertFileType = outputFileType,
            TiffOptions = { Compression = TiffOptions.TiffCompression.Ccitt4},
            HorizontalResolution = 203,
            VerticalResolution = 192,
        };
        

        var convertedDocumentPath = conversionHandler.Convert(Common.inputGUIDFile, saveOptions);

        for (int pagenum = 1; pagenum <= convertedDocumentPath.PageCount; pagenum++)
        {
            convertedDocumentPath.Save("result-" + Path.GetFileNameWithoutExtension(Common.inputGUIDFile) + pagenum.ToString() + "." + outputFileType, pagenum);

        }

Can you please share your sample project with us?

However, you could also try this, download our open-source sample example project from GitHub.
Uncomment following lines in Program.cs:

Common.ApplyLicense(Common.licensePath);
Rendering.RenderImageAsPath(ImageSaveOptions.ImageFileType.Tiff);

Define/set source file:

Common.inputGUIDFile = "Test_LongHeaderFolded.eml";

In this way you will get a different output. You can tell us if you face any further issue(s).
Moreover, we would like to tell you that you can adjust image’s vertical and horizontal resolutions as implemented in the above code snippet.

Also, try tif to tif conversion using the code (by adjusting vertical or horizontal resolutions) we shared or the sample project and share your feedback. In case of any issue(s) we shall surely help you out.

I tested this case with your code and it works like it should.

However, we are calling the Convert method with a stream parameter. I tested your code with a stream parameter and managed to reproduce the issue:

For eml files with long headers (>512 chars), the conversion result is invalid if I change:

var convertedDocumentPath = conversionHandler.Convert(Common.inputGUIDFile, saveOptions);

to:

ConvertedDocument convertedDocumentPath;
using (var inputstream = File.Open(Path.Combine(Common.storagePath, Common.inputGUIDFile), FileMode.Open))
{
    convertedDocumentPath = conversionHandler.Convert(inputstream, saveOptions);
}

So there seems to be some kind of a problem with the stream handling?

Sadly, this had no impact on our tif->tif conversion issue. I will investigate it further.

@jauho,

We reproduced this issue at our end. Hence, it has been logged in our internal issue tracking system with ID:CONVERSIONNET-2508. As we have further updates on it, we shall notify you.

Sure, you can share outcomes here.

@jauho,

We’d like to inform you that CONVERSIONNET-2508 is now fixed in GroupDocs.Conversion for .NET 18.5. Please download latest version of the API and share your feedback.