从邮件正文中读取html格式

本文关键字:读取 html 格式 正文 | 更新日期: 2023-09-27 18:14:40

我正在使用ASCII编码类型的streamReader读取邮件正文,但收到的文本是纯文本格式。它还包含一些特殊字符,如=92,=93,=94,=20等,这些字符与html结尾不同。此外,超链接被转换为文本,如www.google.com http://www.google.com/

调试流。getline函数并找到这些包含content-Type的行,第一行和第二行在主题之前和之后,第三行在邮件正文之前。这三个都不包含text/html。请告诉我该怎么办。

1. Content-Type: multipart/related; boundary=0015174479b83c0db404b1bf7ace
2. Content-Type: multipart/alternative; boundary=0015174479b83c0db104b1bf7acd
3. Content-Type: text/plain; charset=ISO-8859-1

也请找到我正在阅读的邮件:

垃圾标题:垃圾的身体转到{spammy hyperlink}

get中streamReader中的数据为:垃圾邮件标题:**垃圾邮件正文转到spammydomain *

我不知道为什么在每个粗体单词/句子的开头和结尾都附加了*,而链接不被视为链接。在调试其他邮件时,我发现一些字符也被替换了,下面是我发现的列表。

"=85" replaces "..."   on every occurance
"=93"replaces "'""     on every occurance
"=94"replaces "'""     on every occurance
"=92" replaces "'"      on every occurance
"****'r'n" replaces "'n"   randomly
"='r'n" replaces ""         randomly
"=20'r" replaces ""        randomly

我尝试了Html编码/解码,但没有成功。

您能建议任何编码类型或方法来删除所有特殊字符并保留其html格式吗?

从邮件正文中读取html格式

也许你应该开始挖掘一些rfc。我建议:

RFC 822, "ARPA互联网文本消息格式标准", https://www.rfc-editor.org/rfc/rfc822

RFC 2047, <MIME(多用途Internet邮件扩展)第三部分非ascii文本的消息头扩展>, https://www.rfc-editor.org/rfc/rfc2047,特别是4.2。关于"Q"encoding"我认为应该详细说明"特殊字符"。如=92,=93等