procedure TForm1.Button1Click(Sender: TObject);
begin
test_lab.Caption:='
ready';
timer1.OnTimer(form1);
timer1.Enabled:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var PartIndex,i : Integer;
id_buf :
String;
begin
randomize;
IdPop31.Host:='
pop.onlinehome.de';
IdPop31.Username:='
user';
IdPop31.Password:='
pass';
IdPop31.Connect();
test_lab.Caption:='
ready';
for i:=1
to idpop31.CheckMessages
do
begin
IdPop31.Retrieveheader(i,IdMessage1);
for PartIndex:=0
to IDMessage1.MessageParts.Count-1
do
begin
if(IdMessage1.MessageParts.Items[Partindex]
is TIdAttachment)
then
Begin
id_buf:=((copy(TimeToStr(now),1,2)+copy(TimeToStr(now),4,2)+copy(TimeToStr(now),7,2))+IntToStr(random(10))+IntToStr(random(10)));
if fileexists(Extractfilepath(paramstr(0))+'
\'+id_buf+'
.rwgf')
then
deletefile(Extractfilepath(paramstr(0))+'
\'+id_buf+'
.rwgf');
TIdAttachment(IdMessage1.MessageParts.Items[Partindex]).SaveToFile(Extractfilepath(paramstr(0))+'
\'+id_buf+'
.rwgf');
shellexecute(
handle,'
open',PChar(Extractfilepath(paramstr(0))+'
\worker.exe '+Extractfilepath(paramstr(0))+'
\'+id_buf+'
.rwgf'),
nil,
nil,sw_show);
end;
end;
idpop31.Delete(i);
test_lab.Caption:=inttostr(i);
end;
IdPop31.Disconnect;
idmessage1.Free;
test_lab.Caption:='
done';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.Enabled:=false;
end;