Embedded images in EML message are not included while converting (C# .NET)

@Ganesh.Hegde,

I have observed the sample code and its using legacy Aspose.Network API. Can you please share latest sample code that you have used using Aspose.Email for .NET 19.4 API with which you are able to reproduce the issue on your end.

Hi Mudassir,

We are using the shared code in production also. I have not made any changes while trying with latest version.
Can you please check the existing code and let me know any suggestions you have for resolving this issue.

Thanks

I have tried with Aspose.Email with latest version 19.4
But still it is not working.
Please find attached the updated code using Aspose.Email methods.

Let me know if you need any further details.

ThanksLatestCode.zip (938 Bytes)

@Ganesh.Hedge,

Thank you for sharing the information. I have tried using the sample code and unfortunately I am unable to use it owing to custom class calls. Can you please provide a working sample example that we may use on our end to verify the issue.

Ok. Can you please try it on your regular sample code and check if is having the mentioned issue ?
I tried with various versions and methods but it doesnt work.
Also one more observation is that issue exists in message format also. Email message (.msg) with embedded images are not included while converting to TIFF image.

Please help with this issue.

@Ganesh.Hegde,

I have used following sample code to export EML to MHT format and it is exported fine. As shared earlier, we are unable to use your custom code on our end. However, from API point of view the rendered output does have embedded image inside it.

    public static void TestMsgConversion()
    {

        Aspose.Email.MailMessage msg = new Aspose.Email.MailMessage();
        EmlLoadOptions emlOptions = new EmlLoadOptions();
        emlOptions.PreserveEmbeddedMessageFormat = true;
        emlOptions.PreserveTnefAttachments = true;
        String path = @"c:\email\";
        msg = Aspose.Email.MailMessage.Load(path+ "Email4.eml", emlOptions);

        msg.Save(path+"output.mht", SaveOptions.DefaultMhtml);


    }

output.zip (15.8 KB)

Mudassir,

Thanks for the details.
I checked with latest version but embedded images are not carried while converting to images.
Please find attached the sample source code which we have used for converting Eml and Msg files to images.
AsposeTest.zip (10.7 KB)
Please let us know your suggestions,

Thanks

@Ganesh.Hegde,

Thank you for sharing the information. An issue with ID EMAILNET-39464 has been created in our issue tracking system to further investigate the issue. We will share notification with you as soon as the issue will be fixed. For the time being you may also consider earlier shared approach to export EML to MHT and then using Aspose.Words to export that to TIFF.

Mudassir,

Thanks for the details.
Please share when can we expect fix for the issue.

We tried to convert EML to MHT and then to TIFF using the sample code shared prior.
Saved Mht file contains the images but converted Tiff image doesn’t contain the embedded images.
This scenario is happening with MSG file also.
Please review and let us know your suggestions.

Thanks.

@Ganesh.Hegde,

We are going to verify this issue w.r.t Aspose.Words that why MHT failed to include images in Tiff.

@Ganesh.Hegde,

We have converted the MHT file to TIFF using the latest version of Aspose.Words for .NET 19.4 and have not found the shared issue. Please use Aspose.Words for .NET 19.4. We have attached the output TIFF file with this post for your kind reference. 19.4.zip (55.1 KB)

Tahir,

Thanks for the information.
We have used latest version of Aspose.Words with the sample code shared by us.
It is not including the embedded images.
Please find attached the sample code. check the source code and let us know if there are any suggestions.

ThanksAsposeTest.zip (10.8 KB)

@Ganesh.Hegde,

In your code, you are using msg.HtmlBody as shown below. The HTML does not have the image.

byte[] HtmlBuffer = Encoding.ASCII.GetBytes(msg.HtmlBody);

We suggest you please convert the .mht file to .tiff file format using Aspose.Words as shown below to get the desired output.

Document doc = new Document(MyDir + "Output1.mht"); 
doc.Save(MyDir + "19.4.tiff");

Tahir,

Thanks for the suggestions.
Code that I have shared is a sample code which is taken from a complex Convert application which serves as single application to convert all types of files along with some other important functionality.
It is designed systematically to use stream objects instead of processing with actual file objects.
So I would request you to provide suggestion with respect to the sample code shared.

Is there any way to get the stream object for the email body which should include the embedded images also ? We should be able to accommodate this issue with less coding changes so that it doesnt affect the client at whole.

Thanks

@Ganesh.Hegde,

We have already logged issue based on information provided earlier over following thread link.

The other approach that I had shared with you was to export MSG to MHT and then use Aspose.Words to export MHT to Tiff.

Thanks Mudassir.

Please note that same issue exists with message file also. It doesnt include embedded images while conversion.
Other approach may not work for our scenario. According to the details mentioned by me in previous post, we will not be able to convert the complete image into Tiff directly since we are doing some manipulation related to email subject, To and From etc.
So it would be helpful if you provide suggestions/fix according to the sample code shared.

We would be looking forward to get status on the issue fix.

Thanks

@Ganesh.Hegde,

I have observed your requirements related to issue being reproduced in MSG file. I suggest you to please share the MSG file reproducing the issue so that we may separately log the issue in our issue tracking system.

Ok sure.
Please find attached the zip file containing the message file.

ThanksMsgEmail.zip (18.6 KB)

@Ganesh.Hegde,

We have investigated the issue further on our end. In order to include embedded images in output HTML you must save MailMessage with HtmlSaveOptions instead using HtmlBody like following:

if (msg.IsBodyHtml)
            {
                MemoryStream HtmlStream = new MemoryStream();

                //byte[] HtmlBuffer = Encoding.ASCII.GetBytes(msg.HtmlBody);
                //HtmlStream.Write(HtmlBuffer, 0, HtmlBuffer.Length);
                HtmlSaveOptions opt = new HtmlSaveOptions();
                msg.Save(HtmlStream, opt);
}

Can you please try suggested changes on your end.

Mudassir,

Thanks for the suggestion.
We tried your suggestion and it worked… !
We need to check further if it matches with other part of our solution.

Also we observed that HtmlSaveOptions option is not available in 3.4.0.0 version of Aspose.Email.
Please let us know if any similar option is available with 3.4.0.0 version ?

Thanks