Send Email

Could someone help me in creating a send mail button to my app? Where is this “Mail Socket”?

Might I point you to [Example Project] -> [Communication] -> [Internet]
under you XOJO Install

Yes. I read the example…Now what I have is that GMAIL is blocking my attempt to send the email. Suggestions?

My code:

dim SendMailSocket as SMTPSecureSocket
SendMailSocket = new SMTPSecureSocket

SendMailSocket.Address = “” // your SMTP email server
SendMailSocket.Port = 587 // Check your server for the property port # to use

SendMailSocket.ConnectionType = SMTPSecureSocket.SSLv23
SendMailSocket.Secure = True

SendMailSocket.username =“my gmail email”
SendMailSocket.password = “my password”

// Create the actual email message
Dim mail As New EmailMessage
mail.FromAddress = “my gmail email”
mail.Subject = "Pedido de compra do HAMBS nº "+TxtFld_NumeroDoPedido.Text
mail.BodyPlainText = “Autorizamos o envio dos itens relacionados de acordo com as condições especificadas abaixo:”
mail.Headers.AppendHeader(“X-Mailer”, “Sistema de Pedidos de Compra do Hambs”) // Sample header
mail.AddRecipient(“recipient 1”)
mail.AddRecipient(“recipient 2”)

// Add the message to the SMTPSocket and send it

Change your connectiontype property to one of the TLS modes. SSLv2/3 is no longer supported by most servers, including Google.

Also, you should put the declaration of the socket outside of this method. SmtpSecureSocket is asynchronous, and if you let it go out of scope (like you are doing in your code) it’ll never have a chance to finish.

Thanks a lot! Solved.