Issues in converting ".msg" file in Unicode UTF8 format to PDF

I am getting issues (the pdf output is in plaintext of email content) while converting “.msg” file in Unicode UTF8 format to PDF.

Please refer the attachment for the content type and format info of both succeeding and failing “.msg” files.

Code snippet is below and input is a “.msg” physical filename:

    public static IDictionary<int, MemoryStream> GetMessageStream(string filename)
    {
        Aspose.Email.License license = new Aspose.Email.License();
        license.SetLicense("Aspose.Total.lic");

        int index = 1;
        var result = new Dictionary<int, MemoryStream>();
        try
        {
            MailMessage message = MailMessage.Load(filename);
            MemoryStream ms = new MemoryStream();
            message.Save(ms, Aspose.Email.Mail.SaveOptions.DefaultEml);

            message = MailMessage.Load(ms, MailMessageLoadOptions.DefaultEml);
            //Save as MHTML
            // message.Save(ms, MailMessageSaveType.MHtmlFromat);
            result[index] = new MemoryStream(PDFManager.SaveHTMLToPdf(ms));
            if (message.Attachments.Count > 0)
            {
                index++;
                foreach (Attachment item in message.Attachments)
                {
                    string extension = Path.GetExtension(item.Name);
                    MemoryStream content = new MemoryStream();
                    if (extension.ToLower() == ".pdf")
                    {
                        item.Save(content);
                        result[index] = content;
                        index++;
                    }
                    else if (extension.ToLower() == ".doc")
                    {
                        item.Save(content);
                        result[index] = new MemoryStream(PDFManager.SaveDocToPdf(content));
                        index++;
                    }
                    else if (extension.ToLower() == ".docx")
                    {
                        item.Save(content);
                        result[index] = new MemoryStream(PDFManager.SaveDocXToPdf(content));
                        index++;
                    }                        
                }
            }
            return result;
        }
        catch (Exception x)
        {
            throw x;
        }
    }

Capture.JPG (96.2 KB)

@kthiyagarajan,

Please forward us the sample input MSG file. This will help us to reproduce the issue at our end. We will evaluate it and update you about our findings.