I wrote a console app to send email, it works perfectly. Now I’ve tried to add email to a web app written in Xojo 2019 R1.1 (API1). I can see it going out. The appropriate events fire, but it never lands in the destination. I’ve use the same properties for the Mail object and SMTPSecureSocket. So, it must be how I have it coded…
I placed the SMTPSecureSocket object onto a page. Inside a container - on the same page, a button is used to start the process. From the action event of the button, I send a command to the page that the container is on and also has the SMTP object that I had “dragged” onto the page.
Yeah, so the problem is likely that every event that runs in a session is actually happening on a thread and when the response is done, the thread is destroyed.
I would try putting the SMTP object onto the Session class or better yet, into a dictionary in a Module where the keys are the session identifiers so you can release them later.
I have tried this and it still does not work. What I do is in the Container on a Form, I have a button that sends certain fields to a method in the Session. There is the property in the Session for the SMTP object and a method that holds the code to prepare and send to the SMTP object.
The code in the method executes, and via break points can see that SMTP connects etc, but no mail ever arrives.
SendMailSocket = New SMTP
Dim mail As New EmailMessage
SendMailSocket.Address = // your SMTP email server
SendMailSocket.Port = 587 // 995 //587 // Check your server for the property port # to use
// SendMailSocket.SSLConnectionType = MTPSecureSocket.SSLConnectionTypes.TLSv12 // TLSv1
SendMailSocket.ConnectionType = SSLSocket.TLSv12
SendMailSocket.Secure = True
SendMailSocket.Password =
SendMailSocket.Username =