如何在 IdSMTP 的单个连接中发送多封电子邮件?

How to send several emails in a single connection of IdSMTP?

我在 C++Builder 6.0 专业版上使用 Indy 10。

我的 SMTP 服务器在一定时间间隔内对连接数施加了限制,因此我需要使用同一个连接发送多于一封电子邮件。可能吗?我该怎么做?

我已经能够连接并在每次连接时发送一封电子邮件。

非常感谢您的帮助。

您可以在一对 Connect()/Disconnect() 调用之间多次调用 TIdSMTP.Send(),根据需要为每个 Send() 调用调整 TIdMessage .

IdSMTP1.Connect;
try
  // prepare TIdMessage as needed...
  IdSMTP1.Send(IdMessage1);

  // prepare TIdMessage as needed...
  IdSMTP1.Send(IdMessage1);

  // prepare TIdMessage as needed...
  IdSMTP1.Send(IdMessage1);
finally
  IdSMTP1.Disconnect;
end;