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 = "xxxx@server.com"
MailSocket.Password = "yyyyyyyyyy"

// Create email message
Dim mail As New EmailMessage
mail.FromAddress = "xxxx@server.com"
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
mail.AddCCRecipient("xxxx@server.com")

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

// Send e-mail
MailSocket.Messages.Add(mail)
MailSocket.SendMail

Could someone help me, please?.

Thank you very much,
Sergio

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 ?