unit1.pas

来自「精彩编程百例75~100 其中有媒体播放器 SQL语言编辑器 ADO方法连接多个」· PAS 代码 · 共 85 行

PAS
85
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdMessageClient, IdPOP3, ExtCtrls, StdCtrls,shellapi,mmsystem;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    IdPOP31: TIdPOP3;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(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:='';
   IdPOP31.Host := edit1.text;
   IdPOP31.Username := edit2.text;
   IdPOP31.Password := edit3.text;
   label4.caption:='开始查询邮箱';
   IdPOP31.Connect;
   FMsgCount := IdPOP31.CheckMessages;
   i:=FMsgCount;
   if FMsgCount > 0 then
      begin
         label4.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
PlaySound ('newemail.wav', 0, snd_async);
label4.caption:='有新邮件...';
FMsgCount:=IdPOP31.CheckMessages;
edit4.Text:=inttostr(FMsgCount-i);
END;
IDPOP31.DisConnect;
end;


end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?