Problems sending mail from App

I have a desktop application created with Xojo since a few years ago and I want to update the mail server part with Xojo2023r1.1.
I used to use gmail and now I have a custom mail server. I have tried to update the code but it still doesn’t send the mails correctly.

This is my code:

// Connect to server
MailSocket.Port = 465
MailSocket.ConnectionType = SMTPSecureSocket.SSLv23
MailSocket.SMTPConnectionType = SMTPSecureSocket.SMTPConnectionTypes.SSLTLS
MailSocket.SSLEnabled = True

MailSocket.Username = ""
MailSocket.Password = "yyyyyyyyyy"

// Create email message
Dim mail As New EmailMessage
mail.FromAddress = ""
mail.AddRecipient(mEmailClienteActual) // * Recipient's mail
mail.Subject = "Invoice nº " + mInvoiceID + " from My Store"
Dim mensajehtml As string = "<div>Dear client,...</div>"
mail.BodyHTML = mensajehtml
mail.Headers.AddHeader("X-Mailer","Invoice form My Store")

// Send a copy of the e-mail to

// Add attachment
Dim file As New EmailAttachment
file.LoadFromFile(GetFolderItem(mInvoiceID + ".pdf"))

// Send e-mail

Could someone help me, please?.

Thank you very much,

Hello @Sergio_Ciordia1 , welcome to the forum !

Is an error shown, if yes what is it ?

Did you try use the debugger to learn which line fails ? What is your Operating System ?