Autor Beitrag
Hybrid
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112

Win XP Pro
D7 Ent
BeitragVerfasst: Do 19.08.04 14:11 
Also, ich hab hier mal einen Code, der meine mails abholt und die anlagen mit ner id speichert, aber wenn mehr als eine mail auf dem konto ist bekomme ich eine "Zugriffs Verletzung" Meldung.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
procedure TForm1.Button1Click(Sender: TObject); 
var PartIndex,i : Integer; 
         id_buf : String
begin 
randomize; 
IdPop31.Host:='pop.onlinehome.de'
IdPop31.Username:='Username'
IdPop31.Password:='Passwort'
IdPop31.Connect(); 

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'); 
     end
   end
idmessage1.Free; 
idpop31.Delete(i); 
end
IdPop31.Disconnect; 
showmessage('done'); 
end;


Schonmal Danke für die Hilfe!

mfg Hybrid

_________________
Hallo, ich bin eine Signatur! :D
Hybrid Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112

Win XP Pro
D7 Ent
BeitragVerfasst: Do 19.08.04 19:41 
Also, ich hab das obige Problem behoben, aber da is immernoch der Wurm drin. Der Anhang der Mails wird nun nicht erkannt!

Hier ist der aktuelle Code:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
procedure TForm1.Timer1Timer(Sender: TObject);
var PartIndex,i : Integer;
         id_buf : String;
begin
randomize;
 IdPop31.Host:='pop.1und1.de';
 IdPop31.Username:='user';
 IdPop31.Password:='pass';
 IdPop31.Connect();
 test_lab.Caption:='ready';
if idpop31.CheckMessages>0 then
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);
      idpop31.Delete(i);
     end;
   end;
end;
 IdPop31.Disconnect;
 test_lab.Caption:='done';

end;


Bitte helft mir damit, da das die letzte Hürde damit mein Server fertig wird.

mfG Hybrid

_________________
Hallo, ich bin eine Signatur! :D
Hybrid Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112

Win XP Pro
D7 Ent
BeitragVerfasst: Sa 04.09.04 08:24 
Mensch, selbst nach 2 Wochen gibt's keine Antwort!
Bitte versucht mir zu helfen, jetzt wo doch ein Großteil der Community wieder da ist.

_________________
Hallo, ich bin eine Signatur! :D
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: Sa 04.09.04 09:39 
Sorry, falsch gelesen.

Gruß
KidPaddle
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Sa 04.09.04 09:41 
Ich glaube, dass der Fehler ganz einfach ist.

Lass dir mal ausgeben wie Delphi folgendes interpretiert:
ausblenden Delphi-Quelltext
1:
ExtractFilePath(ParamStr(0)) + '\' + id_buf + '.rwgf'					


ExtractFilePath enthält nämlich schon einen '\' am Ende, weshalb dein Pfad nicht existiert, sodass deine Anhänge verschwinden. Denn X:\ABC\DEF\\ghi.rwgf ist nicht wirklich funktionstüchtig.

So sollte es gehen:
ausblenden Delphi-Quelltext
1:
ExtractFilePath(ParamStr(0)) + id_buf + '.rwgf'					

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Hybrid Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112

Win XP Pro
D7 Ent
BeitragVerfasst: Sa 04.09.04 12:06 
Zwar hatte ich mit meinem zusätzlichen / bisher keine Probleme, aber ich kann es ja mal ändern.

Das löst aber leider nicht das Problem, dass die Mail Anhänge garnicht erst erkannt werden!

_________________
Hallo, ich bin eine Signatur! :D
Freiberger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Di 26.06.07 19:10 
Hy,
ich habe es mal versucht, da ich mit Delphi auch Mails senden & empfangen will.
Habe mir deinen Code mal copiert und mir alle Mails in nem StringGrid anzeigen lassen.
( Betreff, Sender usw )
Aber es spuckt mir x-mal die selbe Mail aus ( x=Anzahl meine Mails )

Kann es bei dir sein, daß du gerade eine Mail hast, die keinen Anhang hat ?
Oder muß ich bei IdMessage1 noch was bestimmtes einstellen ??? :roll: