procedure TeMail_Versand.BitBtn1Click(Sender: TObject);
var Ini: TIniFile;
UseLogin: Boolean;
senderName,senderAdresse:
String;
i: Integer;
begin
try
Ini:=TIniFile.Create(prgpfad+'
conf.ini');
UseLogin := Ini.ReadBool('
eMail-Versand','
Login benutzen',True);
SMTP.Host:=Ini.ReadString('
eMail-Versand','
Server','
');
SMTP.Port:=Ini.ReadInteger('
eMail-Versand','
Port',25);
SMTP.Username:=Ini.ReadString('
eMail-Versand','
Benutzername','
');
SMTP.Password:=Ini.ReadString('
eMail-Versand','
Passwort','
');
senderName:=Ini.ReadString('
eMail-Versand','
Name','
');
senderAdresse:=Ini.ReadString('
eMail-Versand','
Adresse','
');
finally
Ini.Free;
end;
SMTP.MailAgent := '
VPlan Plus';
with IdMessage
do begin
Recipients.Clear;
for i:=1
to (VLEEmpfaenger.RowCount-1)
do begin
with Recipients.Add
do begin
Name:=VLEEmpfaenger.Keys[i];
Address:=VLEEmpfaenger.Values[VLEEmpfaenger.Keys[i]];
end;
end;
From.Address:=senderAdresse;
From.
Name:=senderName;
end;
if UseLogin
then
SMTP.AuthenticationType := atLogin
else
SMTP.AuthenticationType := atNone;
IdMessage.Body.Clear;
IdMessage.Body := AnredeEMail.Lines;
IdMessage.Subject := EdBetreff.Text;
TIdAttachment.Create(IdMessage.MessageParts, prgpfad+'
\txt_export\heute.txt');
TIdAttachment.Create(IdMessage.MessageParts, prgpfad+'
\txt_export\morgen.txt');
Try
SMTP.Connect;
SMTP.Send(idMessage);
SMTP.Disconnect;
Except
If SMTP.Connected = True
Then
Begin
Try
SMTP.Disconnect;
Except
MessageDlg('
Konnte Verbindung mit '+
SMTP.Host+'
nicht trennen.', mtError, [mbOK], 0);
End;
End;
MessageDlg('
Konnte eMail nicht verschicken.', mtError, [mbOk], 0);
End;
end;