unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Psock, NMsmtp, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    NMSMTP1: TNMSMTP;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
   //设置SMTP服务器地址、端口
   NMSMTP1.Host:='smtp.263.com';
   NMSMTP1.UserID:='hy';
   NMSMTP1.Port:=25;
   if NMSMTP1.Connect then
      ShowMessage('连接成功!');
   else
      ShowMessage('连接失败!');
   end;
end;end.测试运行时老是出现提示这句出错:
NMSMTP1.Connect此条语句执行后返回的值有两个:true或false,我看来看去的,语法上应该没错啊,但运行时就是出错,还望大家给指点一二,多谢了。测试环境:win sp sp2+delphi5(特意用D5,因为已经自带了NMSMTP控件,虽然D7上的Indy控件更好)

解决方案 »

  1.   

    [code=Delphi(Pascal)]procedure TForm1.Button1Click(Sender: TObject); 
    begin 
      //设置SMTP服务器地址、端口 
      NMSMTP1.Host:='smtp.263.com'; 
      NMSMTP1.UserID:='hy'; 
      NMSMTP1.Port:=25;
      NMSMTP1.Connect; 
      if NMSMTP1.Connect then 
          ShowMessage('连接成功!'); 
      else 
          ShowMessage('连接失败!'); 
      end; 
    end; 
    code]
      

  2.   

    先谢过楼上的指点了,按照楼上的写法测试依然不行,提示如下错误:
    Type of expression must be BOOLEAN这是怎么回事,我记的NMSMTP1.Connect执行后的值应该是true或false啊,但上面的提示却是...