B4J Question [SOLVED]SMTP display which email was sent in multiple email run

Peter Lewis

Active Member
Licensed User
Longtime User
Hi

I have a process which sends email to a group of people. The server sends me a list of emails and then I want to send them and display in a label on the screen the email addresses as they are sent.

Here is the code so far, I read posts that recommend Wait for which I have tried. but it just stops after sending the first email. If I do the smtpx__MessageSent(Success As Boolean) it does show TRUE on the log. as each email is sent. SO I expect it would work in the code below. I have tries with Sleep(50) all over incase it needs that to update the screen.

what I did see if i just do a log in the loop is that it quickly goes through the look and does display all the names but in a fraction of a second and then only displays the last email address all the way thru sending emails.

Here is the code. Any advise would be appreciated. Thank you
B4X:
Sub getemailaddr(emails As List)
Try
    Dim smtp As SMTP
    smtp.Initialize("*******.co.za",465,"******.co.za","************","smtpx")
    smtp.HtmlBody = True
    smtp.UseSSL = True
    smtp.Body = htmlMessage.HtmlText
    Log(emails.Size)
        For x = 0 To emails.Size-1
            smtp.Body = htmlMessage.HtmlText
            smtp.Subject = "Reminder "
            Dim emailinfo() As Object = emails.Get(x)
            smtp.To.Add(emailinfo(0))
            lblMessageSent.Text="Message Sent to "&emailinfo(0)
            smtp.Send
                Wait For smtpx_MessageSent(Success As Boolean)
        Next
    Catch
        Log(LastException)
    End Try  
End Sub
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…