Autor Beitrag
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: So 04.12.05 15:08 
Hier ein ziemlich einfaches POP3 Programm, das mit Indy arbeitet.
Was ihr Braucht :
Ein Formular
Eine ListBox
IDpop3
idMessage
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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdMessageClient, IdPOP3,mmSystem;

type
  TForm1 = class(TForm)
    IdPOP31: TIdPOP3;
    IdMessage1: TIdMessage;
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var i : Integer;
begin
//Der Login

IDPOP31.Host:= Euer Host;
IDPOP31.Username := Username;
IDPop31.Password := Passwort;
IDPOP31.COnnect;
//Caption beschriften
Form1.Caption := 'Sie haben '+Inttostr(IDpop31.CheckMessages+1)+' Nachrichten auf dem Server, die zusammen '+InttoStr(IDpop31.RetrieveMailBoxSize div 1024)+ ' kb groß sind';
If IDpop31.CheckMessages >= 0 THen begin

end;
//Anfang Nachrichten Anzeigen
For i := 0 to IDPop31.CheckMessages do begin
IDMessage1.Clear;
IDpop31.Retrieve(i,IDMessage1);
LIstbox1.Items.Add( IDMessage1.From.Address+'     '+IDMessage1.Subject+'     '+DateToStr(IDMessage1.Date)+'     '+IntToStr(IDpop31.RetrieveMsgSize(i) div 1024)+'kb');
end;
// Ende Nachrichten Anzeigen
//Noch kurz nen schicken Sound abspielen (is optional)
SndPlaySound( 'Post.wav', SND_ASYNC );
//Fertig
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var Zahl,i : Integer;
begin
//Erst mal die IDMessage lehren
IDMessage1.Clear;
// Jetzt gehts ans Text anzeigen

//Jetzt wird bestimmt welche Nachricht wir wollen
Zahl := ListBox1.Itemindex;

//Nun wollen wir die Nachricht mit der Nummer Zahl: in einem Showmessage dialog anzeigen

//vorerst gewünschte Nachricht in die IDMessage1 legen
IDPop31.Retrieve(Zahl,Idmessage1);
//Jetzt ausgeben:
{
Showmessage(IDMessage1.Body.Text);
}

// Ich gebe gerne mehr als nur den Body aus. Und bei MIME mails gehts am besten so ...

for i := 0 to Pred(IdMessage1.MessageParts.Count) do begin
If IdMessage1.MessageParts.Items[i] is TIdText Then begin
ShowMessage('Email von :  '+IDMessage1.From.Address + #13 +'vom :  '+DatetoStr(IDMessage1.Date)+#13+'Betreff :  '+IDMessage1.Subject+#13+#13 +TIdText(IdMessage1.MessageParts.Items[i]).Body.Text);
end;
end;
// ...so könnte es dann aussehen
end;
// Das wärs soweit vom Empfangen
// Anhänge kommen später ...


end.



Ich hoffe ist verständlich

mfg Fighter#1


//Edit
Hab was vergessen (TIDText überpüfung)
Moderiert von user profile iconjasocul: Beitrag befindet sich mit Autor in Diskussion
Moderiert von user profile iconjasocul: Topic aus Delphi Tutorials verschoben am Do 22.06.2006 um 08:20


Zuletzt bearbeitet von Fighter#1 am Fr 05.01.07 15:52, insgesamt 1-mal bearbeitet
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 10.12.05 16:52 
ist nicht wirklich ein tutorial, obwohl alles im source erklärt ist, für sowas müsste es eine codeschnippselsparte geben (gibts leider net, nur units) ansonsten net übl ;)
Ivo@CoMRoK
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 258

Win XP
D3 Prof., D7 Pe.
BeitragVerfasst: Fr 03.03.06 19:50 
Also bei mir mekert der beim RIdText rum ...

_________________
Fällt der Bauer tot vom Traktor, stand am Waldrand ein Reaktor.
Ein altes indianisches Sprichwort besagt:Es kann gefährlich sein gelben Schnee zu essen.
einfach112
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

xp
del7
BeitragVerfasst: Di 18.04.06 21:27 
Titel: also ich finde den text soweit ganz gut ...
naja habe den text mal ein bischen geändert !
ich will die mails direkt auf platte speichern nur das problem ist folgendes
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:
procedure TForm1.Button1Click(Sender: TObject);
var
i :integer;
begin
//Der Login
  idPOP31.Host := 'pop.gmx.net';
  idPOP31.Port := 110;
  idPOP31.Username := 'ich@du.de';
  idPOP31.Password := 'meinpw';
  idPOP31.Connect;
//Caption beschriften
Form1.Caption := 'Sie haben '+Inttostr(IDpop31.CheckMessages+1)+' Nachrichten auf dem Server, die zusammen '+InttoStr(IDpop31.RetrieveMailBoxSize div 1024)+ ' kb groß sind';
For i := 0 to IDPop31.CheckMessages do begin
IDMessage1.Clear;
IDpop31.Retrieve(i,IDMessage1);
LIstbox1.Items.Add( IDMessage1.From.Address+'     '+IDMessage1.Subject+'     '+DateToStr(IDMessage1.Date)+'     '+IntToStr(IDpop31.RetrieveMsgSize(i) div 1024)+'kb');
IDMessage1.Body.savetofile('mails/mail' + IDMessage1.From.Address +' ' + inttostr(i) + '.txt');

 end;
    idpop31.Disconnect;
 end;

end .


das problem ist das die erste mail die ankommt 2 mal gespeichert wird !
einmal mit dem dem absender und der nummer 0 und einmal mit 1
also z.b.
ich@hallo0.txt
ich@hallo1.txt


genau so wird mir in der listbox auch 2 mails angezeigt obwohl ja nur eine da ist !
kann mir da einer sagen wie ich das hinbekomme das die nur noch 1 mal kommt ?
thx schonmal im voraus !
cu
einfach112

_________________
sorry bin noob !
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6386
Erhaltene Danke: 146

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 18.04.06 22:22 
Deine For-Schleife ist falsch.
CheckMessages enthält bei einer Mail den Wert 1.
Da du dann von 0 bis 1 die Schleife zweimal durchläufst, bekommst du auch zweimal die Mail gespeichert.
einfach112
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

xp
del7
BeitragVerfasst: Mo 24.04.06 22:38 
Titel: jo thx für den hinweis !
hat wunderbar geklappt !

_________________
sorry bin noob !
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Di 25.04.06 15:25 
ausblenden Delphi-Quelltext
1:
2:
3:
If IDpop31.CheckMessages >= 0 THen begin

end;


Das verstehe ich nicht

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Sa 06.01.07 13:12 
Hallo,

user profile iconseppens Frage und sämtliche dazugehörigen Antworten habe ich hierhin abgetrennt.

Gruß,
raziel

_________________
JSXGraph