The problem is that you're locked in a cycle. I'm not sure if Application.ProcessMessages is enough for lNet to work. You mustn't do this in a blocking cycle. In other words you can't do a loop in one of the events (of form or anything for that matter) because that means that the GUI doesn't get a chance to process sockets (in visual version, lNet makes use of the widgetset to watch the sockets).
What you need to do is this:
1. based on some event (can be on form create, or a button or whatever initially), read the 1st part of your file, compose a mail and send it
2. wait for OnSuccess with Status = ssRset, when that happens, read next mail and send again (could be same procedure somewhere for simplicity)
3. once the last mail is read/send, then set some variable to the next OnSuccess doesn't try to send the next one
so something like this: (pseudocode)
procedure Form.OnCreate;
begin
Finished := False; // wether we read all mails
PrepareMailFile; // opens the file for reading etc. how you do it, if a filestream or something else is irrelevant
SendNextMail;
end;
procedure Form.SendNextMail;
var
mail: TMail;
begin
try
{ reads next mail from the mails file, composes it into TMail for example, sets Finished to True if no more mails can be read (EOF = true or so) }
mail := GetNextMail;
if Assigned(mail) then // if there was a mail still in the file
SMTP.SendMail(mail); // send the mail
finally
mail.Free; // don't forget to free :)
end;
end;
procedure Form.SMTPSuccess(const aStatus: TLSMTPStatus);
begin
case aStatus of
ssRset: if not Finished then SendNextMail; // if we still were able to read a mail from the file, send it
ssData: Log('Successfully sent a mail'); // could be "which mail" or more specific of course, just for illustration
end;
end;
procedure Form.OnFailure(const aStatus: TLSMTPStatus);
begin
case aStatus of
ssData: Log('Mail sending failed'); // possibly stop the loop, set finished to true etc.
end;
end;
So basically, you read data from file, compose a TMail out of them and then send it, and when sending is finished you repeat the whole thing until the last mail is sent.
This has also the advantage that it won't block your GUI (not sure if Application.ProcessMessages is enough to be completely non-blocking for gui stuff).