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

Check also Build New Mail Message

procedure TForm1.btnSendClick(Sender: TObject);   
begin   
   clSMTP1. MailMessage := clMailMessage1;   
 
   clSMTP1.Server := 'mail.test.com';   
   clSMTP1.UserName := 'test';   
   clSMTP1.Password := 'test';   
   clSMTP1.UseSasl := False;   
   clSMTP1.Open();   
 
   clMailMessage1.BuildMessage('Hello, world !', ['Project1.dpr']);   
   clMailMessage1.From.FullAddress := 'testuser@test.com';   
   clMailMessage1.ToList.Add('support@mywebsite.com');   
   clMailMessage1.Subject := 'Hello';   
 
   clSMTP1.Send();   
 
   clSMTP1.Close();   
end

Add Feedback