unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, mmsystem, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdMessageClient, IdPOP3, ExtCtrls, StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Button1: TButton;
    Timer1: TTimer;
    IdPOP31: TIdPOP3;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  i,FMsgCount:integer;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
if IdPOP31.Connected then
begin
IdPOP31.Disconnect;
end;
edit4.Text:='';
end;
IdPOP31.Host:=edit1.text;
IdPOP31.Username:=edit2.text;
IdPOP31.Password:=edit3.text;IdPOP31.Connect;
FMsgCount:=IdPOP31.CheckMessages;
i:=FMsgCount;
if FMsgCount>0 then
begin
label1.caption:='邮箱中没有新邮件...';
end
else
begin
showmessage('No messages on server');
end;
 IdPOP31.disConnect;
 timer1.Enabled:=true;
 end; procedure TForm1.Timer1Timer(Sender:TObject);
 begin
 IdPOP31.Connect;
 if (IdPOP31.CheckMessages>FMsgCount) then
 begin
label1.caption:='有新邮件...';
FMsgCount:=IdPOP31.CheckMessages;
 edit4.Text:=inttostr(FMsgCount-1);
 end;
  IdPOP31.DisConnect;
 end;
end.[Error] Unit1.pas(42): Declaration expected but identifier 'IdPOP31' found
[Error] Unit1.pas(51): Undeclared identifier: 'label1'
[Error] Unit1.pas(53): '.' expected but 'ELSE' found
[Error] Unit1.pas(54): Identifier redeclared: 'Finalization'
[Warning] Unit1.pas(56): Text after final 'END.' - ignored by compiler
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

解决方案 »

  1.   

    IdPOP31.Host:=edit1.text; 
    IdPOP31.Username:=edit2.text; 
    IdPOP31.Password:=edit3.text; IdPOP31.Connect; 
    FMsgCount:=IdPOP31.CheckMessages; 
    i:=FMsgCount; 
    if FMsgCount>0 then 
    begin 
    label1.caption:='邮箱中没有新邮件...'; 
    end 
    else 
    begin 
    showmessage('No messages on server'); 
    end; 
    IdPOP31.disConnect; 
    timer1.Enabled:=true; 
    end; 这段话你是写在哪儿的?上面那个Button1Click过程都结束了...