Re: IDSmtp

Giganews Newsgroups
Subject: Re: IDSmtp
Posted by:  Michael Johnson (architeuthis6…@yahoo.com)
Date: Mon, 14 Aug 2006

Bill, you have a try...finally with no 'except' clause. You are probably failing with an exception and since you have no 'except' the finally clause catches the exception and supresses it. The point of finally is to execute whether there was an exception or not--finally is where you do cleanup. I believe you want to do something like this:

try
  begin
    Connect(10):
    Send(MyMessage);
  end;
except
  on E : Exception do
  begin
    ShowMessage('Exception class name = '+E.ClassName);
    ShowMessage('Exception message = '+E.Message);
  end;
finally
  // this code will always execute on success and failure--
  // typically people do cleanup here, not a success message
end;

> Sample Code:
>        with MyMail do
>        begin
>          Connect(10);  // with and without the (10)
>          try
>            if MyMail.Connected then
>            begin
>              Send(MyMessage);  // this never executes .......
>            end
>            else begin
>                ShowMessage('Error - Failed to Connect.');  // This never =
> executes........
>                Beep;
>                Exit;
>            end;
>          finally
>              Showmessabe('Email has been sent.');  // This Always displays.....
>          end;
>          Disconnect;
>        end;

-- Mike

Replies

In response to

IDSmtp posted by Bill Slaughter on Sun, 13 Aug 2006