问题
I'm trying to obtain mail body in HTML format. For some mails MailItem.HTMLBody returns string with ��� characters.
Visual Studio Text Visualizer output:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<!-- default_css --><style></style><!-- default_css -->
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>������ ����������� �� ��������-�������
MailItem.InternetCodepage for this mail returns 1251. Outlook displays the mail correctly.
As far as I know, this string is beyond repair from the add-in code, even if I know the original codepage. I would really like to know if there's another way to get HTML body with specified encoding.
PR_HTML_BODY contains <title>������ ������
,
PR_HTML contains <title>Ëè÷íîå ïðèãëàøåíè
.
If I save the mail as file and then open it, Outlook is no longer able to decode it.
回答1:
MailItem.HTMLBody returns a Unicode (UTF-16) string, not an 8 byte encoded string, so code page does not really apply.
What do you see for the PR_HTML MAPI property in OutlookSpy (click IMessage button)?
来源:https://stackoverflow.com/questions/32841042/outlook-mailitem-htmlbody-encoding