Free Support Forum - aspose.com

Wrong PDF format generated after convertion from email

Hi ,

When we try to convert an email to PDF, then we get generated a file which is not correct PDF (please try to open the attached file in Acrobat Reader). We are using Aspose version 18 (NOT Trial version but we have purchased the real product!).

Test Mail.pdf (551.4 KB)

Do you have any idea how I can solve this problem?

My code is:

    private static void ConverFromMailMessage(FileInfo fileInfo, MemoryStream memoryStream)
    {
        var message = Aspose.Email.MailMessage.Load(fileInfo.FullName);
        message.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(message.Date);

        var mhtSaveOptions = new Aspose.Email.MhtSaveOptions
        {
            MhtFormatOptions = Aspose.Email.MhtFormatOptions.WriteHeader |
                               Aspose.Email.MhtFormatOptions.WriteCompleteEmailAddress,
            SkipInlineImages = false
        };

        message.Save(memoryStream, mhtSaveOptions);
        memoryStream.Position = 0;

        var options = new Aspose.Words.LoadOptions()
        {
            LoadFormat = Aspose.Words.LoadFormat.Mhtml
        };

        var document = new Aspose.Words.Document(memoryStream, options);
        document.Save(memoryStream, Aspose.Words.SaveFormat.Pdf);
    }

@axaz,

We have investigated the issue at our end. Email to PDF conversion is working fine. It seems that the issue is related to some specific file. Please share the sample input file with us for further investigation.

Sorry, it was my fault.
When I use a input and output stream, then it works.

BR,
Akbar

@axaz,

Thank you for update. It is good to know that thing are working at your end.