Outlook MailItem.HTMLBody编码 [英] Outlook MailItem.HTMLBody encoding

查看:551
本文介绍了Outlook MailItem.HTMLBody编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取HTML格式的邮件正文.对于某些邮件,MailItem.HTMLBody返回带有 字符的字符串.

Visual Studio文本可视化器输出:

<!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返回1251.Outlook会正确显示该邮件.

据我所知,即使我知道原始代码页,该字符串也无法从附加代码中修复.我真的很想知道是否还有另一种方法来获取具有指定编码的HTML正文.

PR_HTML_BODY包含<title>������ ������, PR_HTML包含<title>Ëè÷íîå ïðèãëàøåíè.

如果我将邮件另存为文件,然后打开它,则Outlook将不再能够对其进行解码.

解决方案

MailItem.HTMLBody返回Unicode(UTF-16)字符串,而不是8字节编码的字符串,因此代码页实际上并不适用.

您在 OutlookSpy (单击IMessage按钮)中看到PR_HTML MAPI属性吗?

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.

解决方案

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)?

这篇关于Outlook MailItem.HTMLBody编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆