c# - 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 };
我哪里错了?
解决方案
正如jdweng指出的,大多数邮件客户端不支持 RTF。
据我所知,谷歌邮件仅支持 HTML 和纯文本消息。
我尝试通过使用 Outlook 向 GMail 发送 RTF 消息来测试这一点,但是,我的 Exchange 服务器总是通过将 RTF 转换为 HTML 来覆盖 RTF,因此 GMail 总是接收 text/html 而不是 text/rtf。
如果我将 Outlook 配置为通过某个非 Exchange 帐户发送,我也许可以让 Outlook 发送文本/rtf,但我懒得打扰。
推荐阅读
- python - 使用存储在 CSV 文件中的值更新 LXML 属性
- php - PHP 到嵌套对象 JSON 输出
- .htaccess - 从 .htaccess 中的 HTTP/HTTPS 重写中排除特定浏览器(Puffin 和 Photon)
- pyephem - 使用 dec/ra 计算月下位置的困惑
- mysql - 从带代理的 CORE 连接到 Google Cloud SQL 实例:发生与网络相关或特定于实例的错误。我可以通过 mysql cmd 连接
- python - 如何计算 Python 中 -30% 到 +30% 误差范围内的测试数据百分比?
- r - 在 R 中生成子表
- r - 气象数据重组
- powershell - 在传递变量时将 PowerShell 脚本启动到新窗口
- python - 用 DRY 解决方案替换多个条件