Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Cannot send email with SSL
ServerSMTP and portSMTP 465 are ok
tested with smtp.gmail.com 465 sslSMTP=true
Matybe something related to TSL_1.1/1.2 ?

What I have tried:

Dim SmtpClient As New SmtpClient(ServerSMTP, portSMTP)
Dim mail As New MailMessage()
SmtpClient.EnableSsl = sslSMTP
SmtpClient.Timeout =2000
SmtpClient.UseDefaultCredentials = False
SmtpClient.Credentials = New Net.NetworkCredential(UserSMTP, pswSMTP)
mail.From = New MailAddress(mittente)
For i As Integer = 0 To Destinatari.Length - 1
    mail.To.Add(Destinatari(i))
Next
mail.Subject = Oggetto
mail.IsBodyHtml = IsHtml
mail.Body = Corpo
SmtpClient.Send(mail)
Posted
Comments
Michael_Davies 4-Dec-22 8:12am    
What is the error message, add a Try Catch around the send and catch the error message.

I have similar code using Gmail, apart from actual values, the only extra I add is the SMTPClient Delivery method set to Network but not likely to be a problem.
BigMax 4-Dec-22 8:30am    
InnerException = {"Impossibile leggere dati dalla connessione del trasporto: net_io_connectionclosed."}

Impossible to read data from transport connection
BigMax 4-Dec-22 8:26am    
thx Michael, yes its in try-catch

in System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
in System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
in System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
in System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
in System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
in System.Net.Mail.SmtpClient.GetConnection()
in System.Net.Mail.SmtpClient.Send(MailMessage message)
Michael_Davies 4-Dec-22 9:17am    
Looking at MS documentation they recommend not using SMTPClient but Mailkit instead, for reasons of security (looks like I'll have to update my old app.).

https://stackoverflow.com/questions/20228644/smtpexception-unable-to-read-data-from-the-transport-connection-net-io-connect
BigMax 4-Dec-22 9:56am    
yes, downloading Mailkit
thx have a nice day

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900