Free Support Forum - aspose.com

Get Body Text of MSG File, But it looks different from how it looks in Outlook

Hello Aspose Supporter.
I am using Aspose.Mail version 20.10.0.0 to read msg file and also mails from mailbox using Imap.
I am using example code like that:

        AppEnv.SetAsposeLicence();
        byte[] bytes = File.ReadAllBytes(@"D:\Developmenet\Casenet\TestMailTicket117630\This is test mail Line Break.msg");

        using (MemoryStream stream = new MemoryStream(bytes))
        {
            stream.Seek(0, SeekOrigin.Begin);
            // Create an instance of MapiMessage from file
            MailMessage msg = MailMessage.Load(stream);

            // Get subject
            Console.WriteLine("Subject:" + msg.Subject);

            // Get body
            Console.WriteLine("Body" + msg.Body);

        }

But in msg.body, there are many line break than how original msg looks like in outlook.
See the picture below to understand my problem:
image.png (166.7 KB)
Do you know the reason why? Is there any solution for us to avoid that thing?

I also attach msg file in zip file for you, so you can debug.
This is test mail Line Break.zip (12.5 KB)

Thank you very much for your support

Yours,
Nghia

@nguyen.xuan.nghia,
Thank you for the issue description. I have reproduced the problem and got the same results with Aspose.Email 21.1. I have logged the issue in our tracking system with ID EMAILNET-40107. Our development team will investigate it. You will be notified when it is fixed.

@nguyen.xuan.nghia
We have investigated the issue. Thank you for your patience. In Outlook you can see the HTML representation of the message body. If you look at the message properties using OutlookSpy or MFCMAPI, you can see that the text representation (stored in the PR_BODY_W property) exactly matches the text representation of the MailMessage body text.png (32.8 KB). You can also see that the HTML body of MailMessage corresponds to what the Outlook shows html.png (9.5 KB).

@Andrey_Potapov
Thank you very much for your answer.

I still have another question:
Is it possible to get plain text(none html) which the same like it looks in outlook?

See my picture to understand I want to get
image.png (54.1 KB)

I want that thing because: If I get the text from PR_BODY_W to show in UI of my application, it makes user confuse, it does not correspond to what the Outlook shows.

Thank you very much for your support.
Yours,
Nghia

@nguyen.xuan.nghia
I have reopened the issue in our tracking system. Our development team will investigate it. I will inform you about any progress a little later.

@Andrey_Potapov
I also want to give you more information.
I used different Aspose.Mail libraries version to test the same msg file which I sent you before, and I saw this thing:

  1. Aspose.mail 19.5.0.0, there is less space, still not the same like in outlook, but it could be acceptable.
  2. Apose.mail 20.10.0.0, too much space

Please see my image to understand my result:
image_2021_02_23T06_40_13_719Z.png (49.5 KB)

Thank you very much for checking the problem.
Yours,
Nghia.

@Andrey_Potapov
I think we have to start again from beginning. Forget all our discussion before.

Because I want to ask you again my problem, it maybe be easier to solve my problem.

I put my new questions in picture below:
questionsAboutShirtEnterAndEnterInOutlook.jpg (136.7 KB)

Thank you very much for your checking and answer my question.

Yours,
Nghia

@nguyen.xuan.nghia,
Thank you for the additional details. I have sent this information to our development team. We will investigate this case.

@nguyen.xuan.nghia,
You can get the desired result from the HtmlBodyText property when it is fixed in Aspose.Email 21.2.

@Andrey_Potapov
Thank you very much for your feedback.
But there is still a thing is not clear for me.
I just has license which has 20210112.
It means the license can not be used with Aspose.Email 21.2.

Will you not fix the problem in old version which my license still can use with?
Can you also fix the problem in the version which my license can use with?

Thank you very much for your feedback.

Yours,
Nghia

@nguyen.xuan.nghia,
To my regret, we cannot fix it for old versions of Aspose.Email. You should update your license to use the latest versions.