Send e-mail with text rtf to delphi

I would like to accomplish the following task: converting the contents of TRichEdit (rtf text) into the body of a non-plain text email message.

MAPI does not support rtf, but is there a way to do this, possibly with Indy?

The problem is that rtf is rtf, and emails are plain text or HTML.

Can anyone suggest a trick? Is it possible to convert rtf to text using TWebBrowser?

Basically the scenario:
1) The user writes an email in delphi form,
2) The email is then sent from MAPI to the default email client (so that a new email window is created, and the message body is the same as in delphi form)
3) The user sends an email from the mail client

In any case, MAPI only accepts plain text.

UPDATE:

Trying with Indy, I wrote this, but still it did not work, as I send mail to my gmail account, I get a message with an empty body and a fake NONAME attachment.

uses IdMessageBuilder;


procedure SendMail;
var
  MBuilder: TIdMessageBuilderRtf;
  MyMemoryStream: TMemoryStream;
begin
  try
    MBuilder := TIdMessageBuilderRtf.Create;
    MyMemoryStream := TMemoryStream.Create;
    MBuilder.RtfType := idMsgBldrRtfRichtext;
    // RichEdit1 has PlainText set to False
    // at design time I pasted some formatted text onto it
    RichEdit1.Lines.SaveToStream(MyMemoryStream);
    MBuilder.Rtf.LoadFromStream(MyMemoryStream);
    MBuilder.FillMessage(IdMessage1);
    IdSMTP1.Connect;
    IdSMTP1.Send(IdMessage1);
    IdSMTP1.Disconnect;
  finally
    MyMemoryStream.Free;
    MBuilder.Free;
  end;
end;
+5
source share
3 answers

Indy RTF. , HTML- , "text/rtf", "text/richated" "text/richtext" Context-Type RTF-, TRichEdit, PlainText false. , Indy 10, TIdMessageBuilderRtf, TIdMessage.

+7

- ( , Delphi, ), PR_RTF_COMPRESSED () MAPI . this.

+1

rtf TWebBrowser?

RTF Text TRichEdit - , , :

TRichEdit

2: RTF- - , . :

http://wiki.delphi-jedi.org/wiki/JVCL_Help:TJvRichEditToHtml https://www.habarisoft.com/scroogexhtml_delphi.html http://www.easybyte.com/products/rtf2html.html

http://www.sautinsoft.com/products/rtf-to-html/index.php

3: noname NONAME.MHT, Internet Explorer.

However, you may need to use the HTML editing control, not TRichEdit. Then you don’t have a conversion to worry about. Something like this question: -

WYSIWYG HTML Editor Component for Delphi

+1
source

All Articles