Send automatic email SSL Implicit ASP.NET VB

Viewed 34

this code is inside a "for next" loop and sends an email through an implicit SSL server.

Last week I had to change the smtp server and now this new smtp server has a block that does not allow simultaneous connection to more than 5 users.

If the for loop sends more than 5 emails I get the error "Too many simultaneous connections". I think this occurs because the emails are sent in a NON ASYNCHRONOUS way and consequently the sending of the email takes too long.

I would like to ask if it is possible to use CDO.message ASYNCHRONOUSLY or if you can recommend another code that sends emails synchronously using an implicit SSL server.

Thank you

            Dim objEmail = CreateObject("CDO.Message")
            Dim objConf = objEmail.Configuration
            Dim objFlds = objConf.Fields


            With objFlds
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPport
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = cdoTimeout
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasicAuth
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailusername
                .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailpassword
                .Update()
            End With


            objEmail.To = email_cli
            objEmail.From = ConfigurationManager.AppSettings("p_email")

            
            objEmail.Subject = mailOggetto
            objEmail.HTMLBody = testo_email

            Try

                objEmail.Send()
            Catch ex As Exception
                FailureText.Text = ex.Message
                Exit Sub
            Finally
                objEmail = Nothing
                objConf = Nothing
                objFlds = Nothing
            End Try
0 Answers
Related