Convert digitally signed msgs to TIFF

Greetings,

I am trying to convert MSG files to TIFF format using Aspose.Email. I am able to successfully convert the normal MSG files to TIFF using the following steps:

  • Load the MSG file to MailMessage object with MessageFormat as MessageFormat.Msg
  • Save the MailMessage object to memory stream using MailMessageSaveType.MHtmlFormat
  • Create Document object
  • Call Document.Save method with SaveFormat.Tiff

But I am unable to generate the TIFF file a digitally signed MSG file. Can any one suggest any solution to this?

Thanks.

Regards,
Syed.

Hi Syed,


Thank you for inquiry.

Could you please post a sample digitally signed MSG and the output TIF file? I will check at my end.

Saqib,

Unfortunately, I will not be able to forward you a sample at this stage.

The TIFF is never generated for the said message file because exception is generated when we try to load the message in the Document object.

I tried to identify the file format of the digitally signed message using the FileFormatUtil.DetectFileFormat method and it returned ‘Unsupported format’. I think this is the reason due to which the exception is generated when I try to load the message data to the Document object.

Any thoughts?

Regards,
Syed

Hi Syed,


Do you mean to say that the MHTML file which is created with Aspose.Email failed to load in Aspose.Word’s Document object? This could either be related to the digital signature issue or a separate issue, but we will be needing an example of such file with which we can reproduce the issue.

Saqib,

I am trying to get hold of a sample for you. But unfortunately, till now I have not been authorized to do so. I will keep you posted on this.

But here with I am attaching a couple of messages that are plain messages containing unicode. When ever I try to load the MHTML stream of these messages in the Aspose.Words.Document object it generates the exception “Cannot access a closed stream.” where as the same piece works fine with non-unicode messages. Following is the piece of code that I am using to load these and the digitally signed messages:

using (MailMessage message = MailMessage.Load(fileName, MessageFormat.Msg))
{
using (MemoryStream msgStream = new MemoryStream())
{
message.Save(msgStream, MailMessageSaveType.MHtmlFromat);

msgStream.Position = 0;
LoadOptions options = new LoadOptions(LoadFormat.Mhtml, string.Empty, string.Empty);
Document doc = new Document(msgStream, options);

doc.Save(outputFile);
}
}

Kindly update me what is missing from my end.

On top of this, I would like to add one more thing. Once you are able to generate the TIFF file the very first page contains the detailed header of the MSG. Which is really annoying. Is there any way to hide that information in the final output?

Lastly, I am now using Aspose.Email.dll version 1.1.0.0. And in this update I find that you have added the formatting to the MHTM header. Although this is better than the previous version’s output but this time there is almost no space between keywords and data. Can you kindly look into this as well?

Thank you in advance.

Regards,
Syed.

Hello Syed,


Thanks for the sample files, I managed to reproduce the issue as well, the problem seems to be with the MHTML files, these could not be opened with MS Word as well. I have logged this issue (ID: 32080), we will look into it further.

You may hide the header information from MHT file using MailMessage.WriteHeaderToMht property.

Regarding the space between keywords and data, could you please explain which keywords? A sample MSG would be helpful.

Saqib,

By setting the MailMessage.WriteHeaderToMht property to false the complete header information is lost including the From, To, Sent On, Subject, etc. My point was that I require the following formatted information: From, Sent, To, Subject, Attachments, etc. But the detailed XML thing is not required. Any suggestion in this regards?

Regards,
Syed.