Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TAdvRichEditor
Sending TAdvRichEditor formatted text by email

Sending an email with the formatted text created by TAdvRichEditor is really simple. To do so, drop a TAdvRichEditor on the form and the Indy idSMTP component. The content of the TAdvRichEditor can be sent with:

var
  msg: TIdMessage;
  Textpart: TidText;

begin
  msg := TIdMessage.Create(self);

  try
    msg.ContentType := ''multipart/alternative'';

    TextPart := TIdText.Create(msg.MessageParts);
    TextPart.ContentType := ''text/plain'';
    TextPart.Body.Clear;
    TextPart.Body.Text := AdvRichEditor1.ContentAsPlainText;

    TextPart := TIdText.Create(msg.MessageParts);
    TextPart.ContentType := ''text/html'';
    TextPart.Body.Clear;
    TextPart.Body.Text := AdvRichEditor1.ContentAsHTML;

    msg.From.Address := ''developer@delphi.com'';
    msg.From.Text := ''Delphi Developer'';

    msg.Recipients.Add.Address := ''joe.do@mailbox.com'';
    msg.Subject := ''Your message subject here’;
    IdSMTP1.Send(msg);
  finally 
    msg.Free;
  end;

end;