How to build a text mail message with file attachments and send it via SMTP

 
procedure TForm1.btnSendClick(Sender: TObject);
begin
  //Connecting to an SMTP service
  clSMTP1.Server := 'mail.test.com';
  clSMTP1.UserName := 'sender@test.com';
  clSMTP1.Password := 'secret';
  clSMTP1.Open();
 
  //Composing a new message
  clMailMessage1.BuildMessage('A message text follows here.', ['C:\MyFiles\MyDocument.zip']);
  clMailMessage1.From.FullAddress := 'sender@test.com';
  clMailMessage1.ToList.Add('support@mywebsite.com');
  clMailMessage1.Subject := 'Subject line';
 
  //Sending the message
  clSMTP1.Send(clMailMessage1);
 
  //Closing the connection
  clSMTP1.Close();
end;

Add Feedback