function TTMSFrmWorkstationEinstellen.MeldeAmMailServerAn: Boolean;
var
pErrMsg:
string;
begin
pErrMsg := '
';
Result := True;
if IdSMTP1.Connected
then
IdSMTP1.Disconnect(True);
try
IdSMTP1.Host := edtMailHostname.Text;
IdSMTP1.Username := edtMailBenutzerName.Text;
IdSMTP1.Password := edtMailPassWort.Text;
IdSMTP1.Port := edtMailPort.IntValue;
IdSMTP1.Authenticate;
IdSMTP1.Connect;
except
on E:
Exception do
begin
pErrMsg := e.
Message;
if IdSMTP1.LastCmdResult.Code <> '
'
then
pErrMsg := IdSMTP1.LastCmdResult.Text.Text
+ #13#10 + '
--'
+ #13#10 + pErrMsg;
Result := False;
end;
end;
end;
// Eine Testmail senden
procedure TTMSFrmWorkstationEinstellen.SendeEineTestMail;
begin
if MeldeAmMailServerAn
then
begin
IdMessage1.Clear;
IdMessage1.MessageParts.Clear;
IdMessage1.Date := Now;
IdMessage1.CharSet := '
ISO-8859-1';
IdMessage1.ContentType := '
multipart/related + multipart/mixed + text/plain '
+ '
+ text/html + multipart/alternative + application/pdf ';
IdMessage1.From.Text := edtMailAdresse.Text;
IdMessage1.Sender.Text := edtMailAdresse.Text;
IdMessage1.Recipients.EMailAddresses := '
meine@kabelmail.de';
//edtMailAdresse.Text;
IdMessage1.Subject := '
Testmail';
IdMessage1.Body.Text := '
Sehr geehrte Damen und Herren, ';
try
IdSMTP1.Send(IdMessage1);
Application.MessageBox('
Die Testmail wurde versandt!',
'
BPS WaWi . . .', MB_OK + MB_ICONINFORMATION);
except on E:
Exception do
MessageDlg('
Fehler beim Senden: ' + E.
Message, mtError, [mbOK], 0);
end;
end
else
begin
Application.MessageBox('
Die Anmeldung am Server ist fehlgeschlagen!',
'
BPS WaWi . . .', MB_OK + MB_ICONSTOP);
end;
IdSMTP1.Disconnect(True);
end;