unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask;
type
TForm1 = class(TForm)
Label1: TLabel;
useredit: TEdit;
Label2: TLabel;
Label3: TLabel;
pop3edit: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
passwordedit: TMaskEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
useredit.Text:='startlxuwei';
pop3edit.Text:='pop3.elong.com';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if (useredit.Text<>'') and (passwordedit.Text<>'') and (pop3edit.Text<>'') then
begin
form2:=tform2.create(nil);
form2.show;
end
else
showmessage('please complete all of the fillings');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
useredit.Text:='';
passwordedit.Text:='';
pop3edit.Text:='';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Psock, NMpop3, StdCtrls, ComCtrls;
type
TForm2 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
NMPOP31: TNMPOP3;
StatusBar1: TStatusBar;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure NMPOP31List(Msg, Size: Integer);
procedure NMPOP31ConnectionFailed(Sender: TObject);
procedure NMPOP31InvalidHost(var Handled: Boolean);
procedure NMPOP31ConnectionRequired(var Handled: Boolean);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure NMPOP31Connect(Sender: TObject);
procedure NMPOP31RetrieveStart(Sender: TObject);
procedure NMPOP31Success(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit1,unit3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
with nmpop31 do
begin
attachfilepath:='.';
deleteonread:=false;
timeout:=2000;
host:=form1.pop3edit.text;
userid:=form1.useredit.text;
password:=form1.passwordedit.text;
connect;
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
nmpop31.disconnect;
end;
procedure TForm2.NMPOP31List(Msg, Size: Integer);
begin
listbox1.items.add(inttostr(msg));
end;
procedure TForm2.NMPOP31ConnectionFailed(Sender: TObject);
begin
showmessage('connection failed');
end;
procedure TForm2.NMPOP31InvalidHost(var Handled: Boolean);
var
tmpstr:string;
begin
if inputquery('invaild host!','specify a new host:',tmpstr) then
begin
nmpop31.host:=tmpstr;
handled:=true;
end;
end;
procedure TForm2.NMPOP31ConnectionRequired(var Handled: Boolean);
begin
if messagedlg('connection required correct?',mtconfirmation,mbokcancel,0)=mrok then
begin
handled:=true;
nmpop31.connect;
end;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
close;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
nmpop31.getmailmessage(strtoint(listbox1.items[listbox1.itemindex]));
form3:=tform3.create(nil);
form3.show;
end;
procedure TForm2.NMPOP31Connect(Sender: TObject);
begin
with nmpop31 do
begin
getmailmessage(mailcount);
list;
label1.caption:='共有'+inttostr(mailcount)+'封邮件';
disconnect;
end;
end;
procedure TForm2.NMPOP31RetrieveStart(Sender: TObject);
begin
statusbar1.SimpleText:='connect starting';
end;
procedure TForm2.NMPOP31Success(Sender: TObject);
begin
statusbar1.SimpleText:='connecttion success';
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Psock, NMpop3, StdCtrls, ComCtrls;
type
TForm2 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
NMPOP31: TNMPOP3;
StatusBar1: TStatusBar;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure NMPOP31List(Msg, Size: Integer);
procedure NMPOP31ConnectionFailed(Sender: TObject);
procedure NMPOP31InvalidHost(var Handled: Boolean);
procedure NMPOP31ConnectionRequired(var Handled: Boolean);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure NMPOP31Connect(Sender: TObject);
procedure NMPOP31RetrieveStart(Sender: TObject);
procedure NMPOP31Success(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit1,unit3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
with nmpop31 do
begin
attachfilepath:='.';
deleteonread:=false;
timeout:=2000;
host:=form1.pop3edit.text;
userid:=form1.useredit.text;
password:=form1.passwordedit.text;
connect;
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
nmpop31.disconnect;
end;
procedure TForm2.NMPOP31List(Msg, Size: Integer);
begin
listbox1.items.add(inttostr(msg));
end;
procedure TForm2.NMPOP31ConnectionFailed(Sender: TObject);
begin
showmessage('connection failed');
end;
procedure TForm2.NMPOP31InvalidHost(var Handled: Boolean);
var
tmpstr:string;
begin
if inputquery('invaild host!','specify a new host:',tmpstr) then
begin
nmpop31.host:=tmpstr;
handled:=true;
end;
end;
procedure TForm2.NMPOP31ConnectionRequired(var Handled: Boolean);
begin
if messagedlg('connection required correct?',mtconfirmation,mbokcancel,0)=mrok then
begin
handled:=true;
nmpop31.connect;
end;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
close;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
nmpop31.getmailmessage(strtoint(listbox1.items[listbox1.itemindex]));
form3:=tform3.create(nil);
form3.show;
end;
procedure TForm2.NMPOP31Connect(Sender: TObject);
begin
with nmpop31 do
begin
getmailmessage(mailcount);
list;
label1.caption:='共有'+inttostr(mailcount)+'封邮件';
disconnect;
end;
end;
procedure TForm2.NMPOP31RetrieveStart(Sender: TObject);
begin
statusbar1.SimpleText:='connect starting';
end;
procedure TForm2.NMPOP31Success(Sender: TObject);
begin
statusbar1.SimpleText:='connecttion success';
end;
end.