Settings non-english characters in HTMLBody (using Redemption)

M

MA

Hi,

I am using Redemption create Outlook messages.

I have noticed some messages not displaying proper characters in
Outlook. For example: I am creating some messages which has chinese
characters. See below the META tag of the HTML.

<meta http-equiv="Content-Type" content="text/html; charset=big5">

In the C# debugger, I can see "htmlBody" contains correct the
characters but the message showing garbase.

message.HTMLBody = htmlBody; // htmlBody ok


Also the OutlookSpy CurrectItem.HTMLBody shows correct format. Do I
need to set some other properties in Outlook?

Thanks for the advice.

Regards,
MA
 
M

MA

I have noticed, settings the InternetCodepage shows the correct
characters.

--------------------------------------------------
message.HTMLBody = htmlBody;
message.InternetCodepage = 52936;
--------------------------------------------------

Is this the best way to solve the issue?

Regards,
MA
 
M

MA

Yes, I have a helper method which read from the file. The method takes
the file path and encoding.

helper.LoadFromFile(filePath, Encoding.GetEncoding("big5"));

Hope I haven't mis-understood your question. Does my question above
make sense? Do I have to set the "InternetCodepage" property?

Regards,
MA
 
M

MA

Thanks "Dmitry" for your response.

I will try to explain below the source of the message my steps:

1) The Outlook message HTMLBody comes from a external HTML file.
Example of the HTML source:
---------------------------------------------
<html>
<head>
<title>¨C ¤é ¶× ¥« ² ³ø</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<body bgcolor="#FFFFFF" link="#003A9A" vlink="#003A9A" alink="#003A9A"
leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
.......
---------------------------------------------

2) My program read the "charset" value from the HTML (use the default
encoding in first pass), then use the charset value (i.e. "big5") to
decodes to string.
bytes = LoadFromFile(path);
htmlBody = Encoding.GetEncoding("big5").GetString(bytes);

3) Set the Outlook message HTMLBody.
message.HTMLBody = htmlBody

As I said earlier, I can see garbage characters in Outlook message.
Outlook message, view source shows the "charset=big5". If I use the
OutlookSpy-CurrentItem, the HTMLBody inside the OutlookSpy shows
correct format. Why the same message in Outlook client shows garbage
and OutlookSpy shows correct?

Also said earlier, if I set the "InternetCodepage" then the message
shows correctly in Outlook. Any pros and cons about this approach?

Thanks in advance for your suggestions.

Regards,
MA
 
D

Dmitry Streblechenko

That should be Ok, but ideally HTML encoding all characters would be much
better.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Thanks "Dmitry" for your response.

I will try to explain below the source of the message my steps:

1) The Outlook message HTMLBody comes from a external HTML file.
Example of the HTML source:
---------------------------------------------
<html>
<head>
<title>¨C ¤é ¶× ¥« ² ³ø</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<body bgcolor="#FFFFFF" link="#003A9A" vlink="#003A9A" alink="#003A9A"
leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
........
---------------------------------------------

2) My program read the "charset" value from the HTML (use the default
encoding in first pass), then use the charset value (i.e. "big5") to
decodes to string.
bytes = LoadFromFile(path);
htmlBody = Encoding.GetEncoding("big5").GetString(bytes);

3) Set the Outlook message HTMLBody.
message.HTMLBody = htmlBody

As I said earlier, I can see garbage characters in Outlook message.
Outlook message, view source shows the "charset=big5". If I use the
OutlookSpy-CurrentItem, the HTMLBody inside the OutlookSpy shows
correct format. Why the same message in Outlook client shows garbage
and OutlookSpy shows correct?

Also said earlier, if I set the "InternetCodepage" then the message
shows correctly in Outlook. Any pros and cons about this approach?

Thanks in advance for your suggestions.

Regards,
MA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top