SMTPsocket best practice

Hi all,

I have a hard time with my SMTPsocket. I was hoping someone could give me some best practices when using SMTPsockets.
I have to send 1000 separate e-mails with PDF documents in attachments and I like to send them one by one.
I add an emailmessage to the queue and then do SMTPsocket1.Sendmail
Should I wait until the sending is done before adding another message to the queue and calling the method Sendmail again? Or can I keep adding and calling Sendmail ?
How would I detect when sending of one message was done before adding the next message to the queue? When I subclass SMTPsocket, I don’t have a ‘SendComplete’ event.
I’m using RS2012R2.1

Thanks.

Michael

[quote=20625:@Michael Beaucourt]Hi all,

I have a hard time with my SMTPsocket. I was hoping someone could give me some best practices when using SMTPsockets.
I have to send 1000 separate e-mails with PDF documents in attachments and I like to send them one by one.
I add an emailmessage to the queue and then do SMTPsocket1.Sendmail
Should I wait until the sending is done before adding another message to the queue and calling the method Sendmail again? Or can I keep adding and calling Sendmail ?
How would I detect when sending of one message was done before adding the next message to the queue? When I subclass SMTPsocket, I don’t have a ‘SendComplete’ event.
I’m using RS2012R2.1

Thanks.

Michael[/quote]

Are you making your own SMTP socket from class TCPsocket ?

Otherwise why not use MessageSent or MailSent (http://documentation.xojo.com/index.php/SMTPSocket)

If you don’t have MessageSent or MailSent then check your parent class has property “Super” set to SMTPSocket

I’d like to follow-up with Michael’s question. Using the SMTPSocket there are, indeed, MailSent, Error, & ServerError Event Handlers. (The documentation lists an event called SendComplete while discussing the SendProgress event, although that event is not listed elsewhere. Presumably it has been replaced by MailSent.)

At any rate, I have found that the Error event is always called after the MailSent event even when all the messages have been sent, which makes it a bit useless, unless there is something else there that I should be looking for.

BUT, back to Michael’s question… should all of the emails you wish to send be added using Messages.Append and then call the socket method SendMail, or should SendMail be called after each email has been appended?

Each time you call the SendMail it has to reconnect, send the mail and then disconnect, so over the course of a few thousand emails, this will add some overhead to it…

I believe this will be very difficult to avoid if you sent emails to different domains.