本文介绍了Delphi + Indy:连接正常关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

使用D7 + Indy 10最新版本。

Using D7 + Indy 10 latest build.

我的代码正在使用TIdSMTP发送电子邮件。
我在一些最终用户不断获得连接关闭,电子邮件从不发送。

My code is using TIdSMTP to send email.I keep getting "Connection closed gracefully" at some end-users, and the email is never sent.

代码如下:

try
~~~~
~~~~
_idSMTP := TIdSmtp.Create;
with _idSMTP do
begin
  Host := 'myhost';
  Connect;
  try
    Send(_EmailMsg);
    Result := True;
  except
    on E: Exception do
    begin
      MsgDlgErr(Self.Handle, E.Message)
    end
  end;
end;
finally
 _idSMTP.Disconnect;
 _idSMTP.Free;
end;

任何建议?

推荐答案

请阅读

在某些情况下这是一个真正的例外
,你的代码需要处理它。在
其他情况(通常为服务器)中,
是协议的
的正常部分,Indy为您处理此
异常。即使Indy
捕获它,当在IDE
中运行时,调试器将被首先触发。
你可以简单地按F9继续
,而Indy将处理异常
,但在
调试期间不断的停止可能会令人讨厌。在
中,Indy捕获
异常的情况下,您的用户将永远不会在程序中看到
异常,除非
从IDE运行。

In some cases this is a true exception and your code needs to handle it. In other cases (typically servers) this is a normal part of the functioning of the protocol and Indy handles this exception for you. Even though Indy catches it, when running in the IDE the debugger will be triggered first. You can simply press F9 to continue and Indy will handle the exception, but the constant stopping during debugging can be quite annoying. In the cases where Indy catches the exception, your users will never see an exception in your program unless it is run from the IDE.

这篇关于Delphi + Indy:连接正常关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 02:53