如何在RichTextBox中发送保存用户在RTF中提供的格式的电子邮件?

时间:2022-01-15 20:20:33

What I'm trying to do is provide a form where a user can type or cut and past formatted text and be able to send it as an email (similar to outlook). This is required because it's closely resembles the current work flow and these emails aren't being saved anywhere besides people's inboxes. This is obviously a bandage on a bigger problem.

我要做的是提供一个表单,用户可以在其中键入或剪切和过去格式化的文本,并能够将其作为电子邮件发送(类似于outlook)。这是必需的,因为它非常类似于当前的工作流程,并且除了人们的收件箱之外,这些电子邮件不会保存在任何地方。这显然是一个更大问题的绷带。

My current attempt has a RichTextBox that can receive RTF that is copy and pasted but when I try to send the email, it seems that the only options are plain text and HTML. After investigating options for an RTF to HTML library, it seems that they all cost at least $300 but after reviewing how difficult it would be to write the library myself, the money and time is better spent getting a third party option. I'm curious if there is a solution to this problem (sending an email with formatted text) without bringing in a third party library.

我目前的尝试有一个RichTextBox,可以接收复制和粘贴的RTF,但是当我尝试发送电子邮件时,似乎唯一的选项是纯文本和HTML。在研究了RTF到HTML库的选项之后,似乎它们都花费了至少300美元,但在审查了自己编写库的难度之后,花钱和时间更好地花在获得第三方选项上。我很好奇是否有这个问题的解决方案(发送带有格式化文本的电子邮件)而没有引入第三方库。

3 个解决方案

#1


Most email clients can't display email in RTF, and that's just how it is. You can't change the email clients.

大多数电子邮件客户端无法在RTF中显示电子邮件,而这就是它的实际情况。您无法更改电子邮件客户端。

So, you need to send the email in HTML. There's no built-in WinForms control to export formatted text in HTML, unfortunately, so there's no way to accomplish this without third-party code.

因此,您需要以HTML格式发送电子邮件。遗憾的是,没有内置的WinForms控件来导出HTML中的格式化文本,因此没有第三方代码就无法实现这一点。

#2


You need an RTF to HTML converter. You're right, it may not be worth your time to write one. I did anyway. It wasn't too bad because I had some control over the RTF document creation and could prohibit things that I didn't want to translate to HTML. Converting RTF to HTML is basically just a document parser with the ability to replace RTF command verbs with their HTML equivalents.

您需要一个RTF到HTML转换器。你是对的,写一篇可能不值得你花时间。无论如何我做了。这不是太糟糕,因为我对RTF文档的创建有一些控制权,可以禁止我不想翻译成HTML的东西。将RTF转换为HTML基本上只是一个文档解析器,能够用它们的HTML等价替换RTF命令动词。

#3


I ended up finding a free solution: http://www.dreamincode.net/forums/showtopic48398.htm

我最终找到了一个免费的解决方案:http://www.dreamincode.net/forums/showtopic48398.htm

It's not a perfect translation but it's better than any of the pay packages out there.

这不是一个完美的翻译,但它比那里的任何付费套餐都要好。

#1


Most email clients can't display email in RTF, and that's just how it is. You can't change the email clients.

大多数电子邮件客户端无法在RTF中显示电子邮件,而这就是它的实际情况。您无法更改电子邮件客户端。

So, you need to send the email in HTML. There's no built-in WinForms control to export formatted text in HTML, unfortunately, so there's no way to accomplish this without third-party code.

因此,您需要以HTML格式发送电子邮件。遗憾的是,没有内置的WinForms控件来导出HTML中的格式化文本,因此没有第三方代码就无法实现这一点。

#2


You need an RTF to HTML converter. You're right, it may not be worth your time to write one. I did anyway. It wasn't too bad because I had some control over the RTF document creation and could prohibit things that I didn't want to translate to HTML. Converting RTF to HTML is basically just a document parser with the ability to replace RTF command verbs with their HTML equivalents.

您需要一个RTF到HTML转换器。你是对的,写一篇可能不值得你花时间。无论如何我做了。这不是太糟糕,因为我对RTF文档的创建有一些控制权,可以禁止我不想翻译成HTML的东西。将RTF转换为HTML基本上只是一个文档解析器,能够用它们的HTML等价替换RTF命令动词。

#3


I ended up finding a free solution: http://www.dreamincode.net/forums/showtopic48398.htm

我最终找到了一个免费的解决方案:http://www.dreamincode.net/forums/showtopic48398.htm

It's not a perfect translation but it's better than any of the pay packages out there.

这不是一个完美的翻译,但它比那里的任何付费套餐都要好。