SMTPSecureSocket question

Suppose I have a series of emails to send via MailSocket1 (As SMTPSecureSocket). I load them up in the method and do a MailSocket1.SendMail to mail them all as a single batch. Now suppose that I would like to log each, if any, MailSocket1.ServerError, and place relevant data for each such error in a single record (one record per error). For instance, each record would show the Customer ID, Customer Name, Error Number, Timestamp, etc.

When I look at SMTPSecureSocket.ServerError(EmailMessage) documentation, I don’t see a way to tell, let’s say, the position in the message queue that EmailMessage occupied, so I could determine what I need for that particular error log. I can get the EmailMessage.ToAddress, for instance, but not the Email.ListIndex.

Is my only option for this sort of error logging, where each instance is recorded in its own record tied to a Customer, to not do this as a batch email operation? That is, do a separate MailSocket.SendMail for each Customer. That would certainly allow me to capture that Customer’s ID information before executing each SendMail.

The only batch SendMail alternative I can think of is to create a Dictionary (or InMemory SQLite database) that associates each ToAddress with the CustomerID. I would then have SMTPSecureSocket.ServerError fill that object as needed. Of course this assumes no two emails are sent to the same Customer. I don’t like making such an assumption.

I’m hoping someone has dealt with this before, and knows how to use SMTPSecureSocket.ServerError(EmailMessage) in a way I don’t see. I’d also like to have a record for each successfully sent email, using SMTPSecureSocket.MessageSent(EmailMessage).

Subclass EmailMessage and add the properties that you need to track them. In ServerError cast the message back into your class to access the new properties.

I never would have thought of doing that. Thanks, Greg.