procedure TF_Mailverwaltung.ButtonVerbindenClick(Sender: TObject);
var
Button,Button1,Button2 : TRadiobutton;
panel : Tpanel;
i,j :integer;
SL :TStrings;
begin
ButtonVerbinden.Enabled := false;
for i := 0
to msRemotePOP.RemoteInfo.Count -1
do begin
Tpanel(findcomponent('
panel'+inttostr(i))).free;
for j := 0
to 3
do
StringGrid.Cells[j,i+1] := '
';
end;
StringGrid.Height :=70;
Statusbar.Panels.Items[0].Text := '
Verbindung mit POP3Server wird hergestellt';
try
msRemotePOP.Server := Server;
msRemotePOP.UserName := XXXX;
msRemotepop.Password := XXXX;
msRemotePOP.MessageDirectory := '
C:\XXXXX\';
msRemotePOP.WinsockLoaded := true;
msRemotePOP.OpenConnection;
msRemotePOP.UpdateRemoteInfo;
Statusbar.Panels.Items[0].Text := '
Mails werden gelesen';
for i := 0
to msRemotePOP.RemoteInfo.Count -1
do begin
Stringgrid.RowCount:= i+2;
sl := msRemotePOP.RemoteInfo.Items[i].Headers;
for j := 0
to sl.Count-1
do begin
// hier wird der Header ausgelesen
if pos('
Subject:',sl.Strings[j])>0
then begin
StringGrid.Cells[1,i+1] := trim(copy(sl.Strings[j],9,255));
end;
if pos('
Date:',sl.Strings[j])>0
then begin
StringGrid.Cells[3,i+1] := trim(copy(sl.Strings[j],6,26));
end;
if pos('
From:',sl.Strings[j])>0
then begin
StringGrid.Cells[2,i+1] := trim(copy(sl.Strings[j],pos('
<',sl.Strings[j]),255));
end;
end;
StringGrid.cells[0,i+1] := inttostr(i+1);
StringGrid.Height := StringGrid.Height +15;
if F_Mailverwaltung.Height < StringGrid.Height +30
then begin
F_Mailverwaltung.Height := F_Mailverwaltung.Height +100;
end;
end;
// Hier wird dynamisch ein Panel erzeugt auf dem 3 Radiobuttons liegen ehr unwichtig für den ablauf des Programm
for i := 0
to msRemotePOP.RemoteInfo.Count -1
do begin
Button := TRadioButton.Create(self);
panel := TPanel.Create(self);
panel.
Name := '
Panel' +inttostr(i);
panel.Width := 50;
panel.Top := 19 + (17 * i);
panel.Left := 5;
panel.Height := 17;
panel.Caption := '
';
panel.BevelOuter := bvnone;
panel.show;
panel.parent := PanelOben;
button.parent:= panel;
button.
Name := '
MyRadiobutton'+ inttostr(i);
button.Left := 5;
button.Top := 0;
button.Width := 17;
button.Caption := '
';
button.show;
Button1 := TRadioButton.Create(self);
button1.parent:= panel;
button1.
Name := '
MyRadiobutton'+ inttostr(i) +'
a';
button1.Left := 21;
button1.Top := 0;
button1.Width := 17;
button1.Caption := '
';
button1.show;
Button2 := TRadioButton.Create(self);
button2.parent:= panel;
button2.
Name := '
MyRadiobutton'+ inttostr(i)+'
b';
button2.Left := 37;
button2.Top := 0;
button2.Width := 17;
button2.Caption := '
';
button2.show;
end;
except
on E:
Exception do begin
Showmessage('
Der Abruf der Mails ist fehlgeschlagen!');
ButtonVerbinden.Enabled := true;
exit;
end;
end;
StringGrid.Visible:= true;
StatusBar.Panels.Items[0].text := '
Mails erfolgreich eingelesen!';
ButtonVerbinden.Enabled := true;