TIdSMTP.Connect rasises AV

Giganews Newsgroups
Subject: TIdSMTP.Connect rasises AV
Posted by:  Jon (jonsjoste…@hotmail.com)
Date: Wed, 29 Jun 2005

Hi all!
Guess the problem is pretty clear. Here is some code to reproduce it and some code that works.
My question is why is it like this

*** Code with error: ***

unit TestIdSMTP;

interface

implementation

uses
  IdSMTP;
var
  IdSMTP: TIdSMTP;

initialization
  IdSMTP := TIdSMTP.Create(nil);
  IdSMTP.Connect;
finalization
  IdSMTP.Free;
end.

*** Code without error: ***

unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,

  IdSMTP;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var
  IdSMTP: TIdSMTP;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  IdSMTP: TIdSMTP;
begin
  IdSMTP := TIdSMTP.Create(nil);
  IdSMTP.Connect;
  IdSMTP.Free;
end;

end.

Replies