procedure TfrmMain.DateiSenden;
const return = chr(13);
var Daten : Empfaenger;
SearchRec : TSearchRec;
dateiname :
string;
text :
string[18];
ASatz :
string;
FromF, ToF :
file;
bfile : textfile;
NumRead, NumWritten : Integer;
Buf:
array[1..1]
of Char;
begin
// Dateien suchen
if FindFirst(PfadName+'
*.*',faAnyFile,SearchRec)=0
then
begin
repeat
dateiname:=SearchRec.
Name;
// Daten aus der DatenBank holen
Daten:=DepotSuchen(copy(dateiname,4,3));
if daten.
Name <> '
Unbekannt'
then
begin
AssignFile(bfile,PfadName+dateiname);
reset(bfile);
readln(bfile,ASatz);
CloseFile(bfile);
bordero:=copy(ASatz,5,18);
AssignFile(FromF, PfadName+dateiname);
Reset(FromF, 1);
AssignFile(ToF, PfadName+'
temp.dat');
Rewrite(ToF, 1);
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
if ord(Buf[1])=10
then
begin
Buf[1]:=chr(13);
BlockWrite(ToF,Buf[1],NumRead,NumWritten);
Buf[1]:=chr(10);
BlockWrite(ToF,Buf[1],NumRead,NumWritten);
end
else BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0);
CloseFile(FromF);
CloseFile(ToF);
DeleteFile(PfadName+dateiname);
RenameFile(PfadName+'
temp.dat',PfadName+dateiname);
// Datei versenden
with IdMsgSend
do
begin
IdMsgSend.MessageParts.Clear;
TIdAttachment.Create(IdMsgSend.MessageParts,PfadName+dateiname);
From.Text:=Absender;
Recipients.EMailAddresses:=daten.EMail;
Subject:='
test';
SMTP.Connect;
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
end;
DeleteFile(PfadName+dateiname);
end;
until FindNext(SearchRec) <> 0;
FindClose(SearchRec);
end;
end;