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;
source
share