Click here to Skip to main content
15,889,839 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I'm trying to extract html body from outlook .msg file using outlook type library and displaying it on Web-browser control in c#. On my development machine it working perfectly fine, however on the client machine, some of the text from the email is being shown as random chinese characters.
Below is the code to extract & show html from email :

C#
using OL=Microsoft.Office.Interop.Outlook;
            OL.Application olApp = new OL.Application();
            OL.MailItem mail = olApp.Session.OpenSharedItem(txtFile.Text) as OL.MailItem;
            webBrowser1.DocumentText = mail.HTMLBody;


On my machine, part of the email is being shown as:
> then the "Click Here" link.


But on client machine, the same text looks like :
>  and then the 揅lick Here?link.


What I have tried:

**So far this issue only occurs if there is any double quote in the text** but i cannot confirm if this is only related to double quotes.
I have the same outlook version as that of client machine (Outlook 2016).
I tried disabling the outlook's smart quote feature on the client machine but it didn't make any difference.
I suspect that some language setting may be causing this issue.
I tried using some third party libraries like this one
Reading an Outlook MSG File in C#
but it is also giving incorrect results.
I cannot use redemption library due to costing issues.

Any help or guidance would be very appreciated!!
Posted
Updated 20-Mar-18 1:14am
v2
Comments
Richard Deeming 20-Mar-18 9:31am    
Sounds like an encoding issue. Try setting the encoding to UTF-8 after setting the document text:
webBrowser1.Document.Encoding = "utf-8";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900