1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| procedure TForm4.Button2Click(Sender: TObject);
var
IdMessage: TIdMessage;
IdSMTP: TIdSMTP;
begin
IdMessage := TIdMessage.Create(nil);
IdMessage.ContentType := 'multipart/alternative';
IdMessage.From.Address := 'exp@free.fr';
IdMessage.ReplyTo.Add.Address := 'exp@free.fr';
IdMessage.Recipients.Add.Address := 'dest@free.fr' ;
IdMessage.Subject := 'Sujet du message';
IdMessage.Body.Text := memo1.Text;
IdSMTP := TIdSMTP.Create(nil) ;
IdSMTP.Port := 25;
IdSMTP.Host := 'smtp.free.fr';
Try
Try
IdSMTP.Connect;
IdSMTP.Send(IdMessage);
except
on e: exception do MessageDlg(e.Message, mtError, [mbOK], 0);
end;
finally
IdSMTP.Disconnect;
IdSMTP.Free;
IdMessage.Free;
end;
end; |
Partager