Ich habe den Code mal formatiert
(ihr dürft staunen.
)
Das ganze auch im Anhang.
Delphi-Quellcode:
procedure Tfrmmain.btnSendClick(Sender: TObject);
var
i: integer;
begin
SMTP.Host:=editHost.Text;
SMTP.Username:=EditUser.Text;
SMTP.Password:=EditPasswort.Text;
btnSend.Enabled:=False;
try
with email
do
begin
Clear;
From.Text:=Trim(edtFrom.Text);
Subject:=Trim(edtSubject.Text);
Body.Assign(memText.Lines);
end;
SMTP.Host:=editHost.Text;
SMTP.Username:=EditUser.Text;
SMTP.Password:=EditPasswort.Text;
email.Recipients.add.Address:=trim('
mail@domain.de');
for i:= 0
to ltbEmailAdress.count-1
do
begin
email.recipients.add.Address:=trim(ltbEmailAdress.items[i]);
end;
with smtp do
begin
Disconnect;
Connect;
try
Send(email);
finally
showmessage('
Email angekommen');
end;
end;
except
showmessage('
Email nicht angekommen');
end;
btnSend.Enabled:=True;
end;