在Windows XP中使用Indy 10发送带有内嵌图像的电子邮件时的“SMTP传入数据超时”

时间:2009-04-15 17:26:04

标签: delphi email windows-xp smtp indy

当我尝试在Windows XP中发送带有内嵌图像的电子邮件时,我收到错误“SMTP传入数据超时”,我正在使用Indy 10的tiburon分支,并使用以下代码发送带有内嵌图像的电子邮件:

   MB := TIdMessageBuilderHtml.Create;
    try
      MB.PlainText.Assign(Text);
      MB.Html.Assign(FHTML);
      MB.HtmlFiles.Add('c:\Path\to\My\Image.jpg');
      MB.FillMessage(IdMessage);
    finally
      MB.Free;
    end;


  if not IdSMTP.Connected then
    IdSMTP.Connect;
  IdSMTP.Send(IdMessage);

它只发生在Windows XP中,在Windows Vista中,电子邮件和内嵌图像发送得很好。

显然它没有向服务器发送任何内容,它似乎在发送前卡住了图像。

这是调用堆栈:

 IdReplySMTP        497   +1 TIdReplySMTP.RaiseReplyError
 IdTCPConnection    574   +1 TIdTCPConnection.RaiseExceptionForLastCmdResult
 IdTCPConnection    724  +10 TIdTCPConnection.CheckResponse
 IdTCPConnection    563   +2 TIdTCPConnection.GetResponse
 IdTCPConnection    583   +4 TIdTCPConnection.SendCmd
 IdTCPConnection    696   +4 TIdTCPConnection.SendCmd
 IdSMTP             377   +2 TIdSMTP.DisconnectNotifyPeer
 IdTCPConnection    517   +5 TIdTCPConnection.Disconnect
 IdSMTP             476   +2 TIdSMTP.Disconnect
 IdTCPConnection    828   +2 TIdTCPConnection.Disconnect
 Email              130  +11 TEmail.Destroy
 System            9806   +1 TObject.Free
 EnviarEmail        322  +38 TFormEnviarEmail.Enviar
 System           12106  +38 @HandleFinally
                             RtlUnwind
 System           11589  +83 @HandleAnyException
                             KiUserExceptionDispatcher
                             RtlAppendUnicodeToString
 IdMessageClient    873   +4 EncodeAttachment
 IdMessageClient   1213 +252 TIdMessageClient.SendBody
 IdMessageClient   1244 +283 TIdMessageClient.SendBody
 IdMessageClient   1269  +12 TIdMessageClient.SendMsg
 IdSMTPBase         251   +6 TIdSMTPBase.SendNoPipelining
 IdSMTPBase         436   +4 TIdSMTPBase.InternalSend
 IdSMTPBase         457   +1 TIdSMTPBase.Send
 IdSMTP             415   +6 TIdSMTP.Send
 IdSMTPBase         449   +6 TIdSMTPBase.Send

关于导致它的原因的任何线索以及如何解决问题?

感谢。

3 个答案:

答案 0 :(得分:0)

您是否确认可以使用真正的邮件客户端发送相同的邮件,最好是简单易用的邮件客户端,如Mozilla Thunderbird或Opera的邮件客户端,它不会集成到系统的内容中?可能存在一个反病毒/反垃圾邮件/反任何系统干扰 - 其中许多系统透明地拦截传出的25 / TCP并对数据进行处理。

答案 1 :(得分:0)

如果编码不是原因,而是读取超时,则可以使用ReadTimeOut属性增加它:

IdSMTP1.ReadTimeOut:= 20000;

答案 2 :(得分:0)

问题解决了。

我正在解析HTML文件以加载图片并将其附加到电子邮件中,但在Windows XP中路径是:

C:\Documents And Settings\User\Desktop\....

在html文件中,此路径为

C:\Documents%20And%20Settings\User\Desktop\....

因此,在内部引发了一个未找到文件的异常并停止了该过程,直到超时,并且Indy没有提高它。

在Windows XP计算机上运行的进程中附加远程调试器后,我在第一次尝试时遇到异常。

我不认为Indy能够“吞没”这个例外是正确的,但这是另一个历史。