Long time ago I wrote following code to retrieve emails from mailbox:
pop3 := TNMPOP3.Create(Self);
try
pop3.Host := FAppSettings.ServerName;
pop3.Port := FAppSettings.ServerPort;
pop3.UserID := FAppSettings.Login;
pop3.Password := FAppSettings.Password;
try
pop3.Connect;
except
on E:Exception do AddError(E.Message);
end;
if not pop3.Connected then Exit;
if pop3.MailCount > 0 then begin
pop3.DeleteOnRead := False;
pop3.AttachFilePath := GetTempDirectory;
ProcessMsgs(pop3);
end
else begin
TCommon.InfMsg('There are no messages in mailbox');
end;
pop3.Disconnect;
finally
pop3.Free;
end;
Now, when mail service provider switched entirely to SSL this code fails obviously, but in a strange way:
pop3.Connect
line causes an exception but with an empty text in E.Message making the problem unclear to end user.
Investigation of the problem in Delphi debugger reveals that the first time the right exception is generated:
Project .... raised exception class Exception with message 'Authentication failed'.
but then, when I press F8 (Step Over) again, execution point remains in the same line and another exception is generated:
Project .... raised exception class Exception with message ''.
and only this exception is catched by try-except
.
Why?