首页 > 解决方案 > C# MailKit - 如何创建 Rtf 消息

问题描述

我正在尝试以 rtf 格式发送消息,但在接收时,gmail 等无法正确解释它(MacOS 上的 Mail.app 除外)。这是一个示例代码。一些客户端应用程序将其视为“文本”。

String body = @"{\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;} This line is the default color\line \cf2 This line is red\line \cf1 This line is the default color}"
message.Body = new TextPart("rtf") { Text = body };

我哪里错了?

标签: c#mailkit

解决方案


正如jdweng指出的,大多数邮件客户端不支持 RTF。

据我所知,谷歌邮件仅支持 HTML 和纯文本消息。

我尝试通过使用 Outlook 向 GMail 发送 RTF 消息来测试这一点,但是,我的 Exchange 服务器总是通过将 RTF 转换为 HTML 来覆盖 RTF,因此 GMail 总是接收 text/html 而不是 text/rtf。

如果我将 Outlook 配置为通过某个非 Exchange 帐户发送,我也许可以让 Outlook 发送文本/rtf,但我懒得打扰。


推荐阅读