How to send several emails in a single connection

2019-03-06 00:10发布

问题:

I am using Indy 10 on C++Builder 6.0 Professional Edition.

My SMTP server imposes a limit on the number of connections in a certain time interval, so I need to send more than one email using the same connection. Is it possible? How can I do that ?

I am already able to connect and send one email on each connection.

Thank you very much for any help.

回答1:

You can call TIdSMTP.Send() multiple times between a single pair of Connect()/Disconnect() calls, adjusting the TIdMessage as needed for each Send() call.

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;


标签: ssl smtp indy