Reply to thread

The following code was working correctly for over a year. Upgraded to new .net framework and smtpclient.send no longer works and throws an exception. here is the test code:


    Protected Sub Submit_Click(sender As Object, e As System.EventArgs)


        Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()

        mailMessage.From = New       System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings("fromEmail"))

        mailMessage.To.Add(System.Configuration.ConfigurationManager.AppSettings("toEmail"))

        mailMessage.Subject = System.Configuration.ConfigurationManager.AppSettings("EmailSubject")


        mailMessage.Body = mailMessage.Body & "Food Lot Tracking" & Environment.NewLine


        mailMessage.IsBodyHtml = False


        Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()


        Try

            smtpClient.Send(mailMessage)

        Catch ex As Exception

            Server.Transfer("RegisterBadEmail.aspx")

        Finally

        End Try


        Server.Transfer("RegisterOK.aspx")


    End Sub


Thanks in advance for your help.


JR


Continue reading...


Back
Top