这个程序错在哪里(50分)

  • 主题发起人 主题发起人 joove
  • 开始时间 开始时间
J

joove

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个用于检查是否有心邮件到达的程序,编译都通过了,就是没有我想要的结果
unit Unit3;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Psock, NMpop3, StdCtrls;

type
TForm1 = class(TForm)
NMPOP31: TNMPOP3;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure NMPOP31ConnectionFailed(Sender: TObject);
procedure NMPOP31Failure(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
i:integer;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (NMPOP31.MailCount>i) then
showmessage('Sir,you have new mail arrival');
i:=NMPOP31.MailCount;
end;

procedure TForm1.NMPOP31ConnectionFailed(Sender: TObject);
begin
showmessage(' not succeed');
end;

procedure TForm1.NMPOP31Failure(Sender: TObject);
begin
showmessage('ft,联不上');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
NMPOP31.Connect;
i:=NMPOP31.MailCount;

end;

end.
 
都哑巴了?
 
没问题,我试过了
 
sorry
把procedure TForm1.FormCreate(Sender: TObject);中的i:=NMPOP31.MailCount;
放到procedure TForm1.NMPOP31Connect(Sender: TObject);中
 
to wys205:还是不行
 
只有重新连接服务器,MailCount才回改变。
这样就行了:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Psock, NMpop3;

type
TForm1 = class(TForm)
NMPOP31: TNMPOP3;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure NMPOP31ConnectionFailed(Sender: TObject);
procedure NMPOP31Failure(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
i:integer;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled:=false;
NMPOP31.Connect;
if (NMPOP31.MailCount>i) then
showmessage('Sir,you have new mail arrival');
i:=NMPOP31.MailCount;
NMPOP31.DisConnect;
Timer1.Enabled:=true;
end;

procedure TForm1.NMPOP31ConnectionFailed(Sender: TObject);
begin
showmessage(' not succeed');
end;

procedure TForm1.NMPOP31Failure(Sender: TObject);
begin
showmessage('ft,联不上');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
NMPOP31.Connect;
i:=NMPOP31.MailCount;
NMPOP31.Disconnect;
Timer1.Enabled:=true;
end;

end.

 
一直连着信箱是不行的,信箱状态将一直保持在连接前的状态,
所以你也检查不到新的邮件,应该每隔一段时间检查一下
 
ft 还是没结果!
 
我试了的有结果。
是没什么结果?
 
后退
顶部