邮件附件文本在 c# Microsoft.Exchange.WebServices 2.2 中的每个字符前面都有 \0

Mail attachment text has \0 in front of every Character in c# Microsoft.Exchange.WebServices 2.2

我正在使用 C# 的 NuGet 包 Microsoft.Exchange.WebServices 来读取我的邮箱和文本文件附件。

虽然这通常有效,但我现在有一组特定的电子邮件,其中附件的文本内容已关闭。

这是我访问附件的代码:

EmailMessage message = EmailMessage.Bind(service, Mail.Id);
// load attachments
FileAttachment fileAttachment = message.Attachments[0] as FileAttachment;
fileAttachment.Load();
string newSoxAttachment = System.Text.Encoding.Default.GetString(fileAttachment.Content);

这是文件名:

2018-11_GPM-User-Verification-Report.txt

文件应该是这样的(在编辑器中工作):

这是字符串 newSoxAttachment 实际包含的内容:

ÿþ=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=
[=13=]M[=13=]O[=13=]N[=13=]T[=13=]H[=13=]L[=13=]Y[=13=] [=13=]G[=13=]P[=13=]M[=13=] [=13=]U[=13=]S[=13=]E[=13=]R[=13=] [=13=]V[=13=]E[=13=]R[=13=]I[=13=]F[=13=]I[=13=]C[=13=]A[=13=]T[=13=]I[=13=]O[=13=]N[=13=] [=13=]R[=13=]E[=13=]P[=13=]O[=13=]R[=13=]T
[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=

[=13=]R[=13=]E[=13=]P[=13=]O[=13=]R[=13=]T[=13=] [=13=]R[=13=]U[=13=]N[=13=] [=13=]I[=13=]D[=13=]:[=13=] [=13=]R[=13=]I[=13=]D[=13=][=13=][=13=][=13=]
[=13=]R[=13=]E[=13=]P[=13=]O[=13=]R[=13=]T[=13=] [=13=]R[=13=]U[=13=]N[=13=] [=13=]D[=13=]A[=13=]T[=13=]E[=13=]:[=13=] [=13=][=13=].[=13=].[=13=]
[=13=]D[=13=]A[=13=]T[=13=]A[=13=] [=13=]F[=13=]O[=13=]R[=13=] [=13=]M[=13=]O[=13=]N[=13=]T[=13=]H[=13=]:[=13=] [=13=][=13=]-
[=13=]T[=13=]a[=13=]s[=13=]k[=13=] [=13=]V[=13=]e[=13=]r[=13=]s[=13=]i[=13=]o[=13=]n[=13=]:[=13=] [=13=].[=13=]

[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=
[=13=]F[=13=]I[=13=]N[=13=]D[=13=] [=13=]R[=13=]E[=13=]P[=13=]O[=13=]R[=13=]T[=13=] [=13=]D[=13=]A[=13=]T[=13=]A[=13=] [=13=]A[=13=]B[=13=]O[=13=]U[=13=]T[=13=] [=13=]D[=13=]I[=13=]S[=13=]A[=13=]B[=13=]L[=13=]E[=13=]D[=13=] [=13=]U[=13=]S[=13=]E[=13=]R[=13=]S[=13=] [=13=]B[=13=]E[=13=]L[=13=]O[=13=]W[=13=]:
[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=[=13=]=

基本上每个字母前面都有一个[=15=]。我相信这是一个编码问题,但我不知道我需要哪种编码。我已经尝试过 UTF 系列和 default

您正在尝试将 UTF-16 视为 ASCII。在 UTF-16 中,每个基本字符都是 2 个字节宽。

由于您正在查看的字符的代码点低于 255,因此它们具有前导零。

上面的代码类似于 Dragonthoughts 正确表述的 UTF-16。

但是,System.Text.Encoding.UTF-16不可用

因此,使用 System.Text.Encoding.UnicodeSystem.Text.Encoding.BigEndianUnicode

(尝试两者中哪一个适合您)