0

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 Answers1

2

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;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Can I use a new TIdMessage for each email ? I'd like to prepare all emails before sending them. Thank you very much for answering me. – Jayme Jeffman Jan 28 '19 at 13:34
  • 2
    @JaymeJeffman yes, you can use a new `TIdMessage` each time. Or, you can simply `Clear()` a single `TIdMessage` each time, too. – Remy Lebeau Jan 28 '19 at 17:01