Android Question NET/SMTP triggering the MessageSent event


Licensed User
Hello All,

One of my apps needs to send several emails at end of app, usually 2 to 5. I am using the NET library, SMTP component to handle the sending of emails.
I have a list of emails I need to send and wanted to loop through the list, sending one email at a time while waiting for the MessageSent event to trigger. The MessageSent resets a flag to tell the loop, that it is Ok to process the next message.

However, through testing (with a whole lot of debugging code), it seems that the MessageSent trigger only fires when the loop is ended for all iterations (or possibly when the app is inactive). When the loop has exhausted all its iterations, the MessageSent trigger is fired consecutively for the number of file sent.

The loop code looks like
            For kount = 0 To emailsMap.Size-1
                If emailsMap.GetValueAt(kount) = True Then
                    timeKount = 0
                    Do While (okForNext = False)   ' flag set to false by the previous call to resendFile
                        ESCommon.Sleep(1000)   ' Sleep for a second
                End If
The resend procedure sends the SMTP request and sets the okForNext flag to false.

Is there any way to have the MessageSent trigger fire in the middle of the loop? That is the MessageSent firing can take a higher precedence that the loop and temporarily interrupt the the loop to process the MessageSent code?

regards and many thanks



Licensed User
Thanks Erel,
I had a suspicion that that might be the case.
Thanks for your suggestion.