I need a way to loop threw a sql database and send email to the email address in the sql database. Here My connection string
Code:Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("UserDataDB").ToString()Dim con As New SqlConnection(ConnectionString)
con.Open()
Dim CommandText As String = "SELECT NameToUse, EmailAddress FROM NewsLetter"
Dim cmd As SqlCommand = Nothing
cmd = New SqlCommand(CommandText)
cmd.Connection = con
Dim rdr As SqlDataReader = Nothing
rdr = cmd.ExecuteReader()
rdr.Read()
Dim Name As String = rdr("NameToUse")
Dim EmailAddress As Integer = rdr("EmailAddress")
'Loop threw the database and return each record one at a time
SendEmail(Name, EmailAddress)
rdr.Close()
con.Close()