I'm trying to build a VB.NET component that will retrieve a list of email addresses from a database("EmailTest") on my local machine and would send them emails automatically. I'm using a component called Quicksoft.SMTP for the email part. Now when I tested it first by sending email to just one person it worked fine so I know that ther is no problem in the emailing part of it. Its the dataset retrieval that is causing problems and I think its not reading from the database for some reason. I'm new to VB.NET so I can't figure out what is wrong. Could you please look at my code and point to what might be the problem.
Dim conEmail As SqlConnection
'Dim strSelect As String
Dim cmdSelect As SqlCommand
Dim dtrEmail As SqlDataReader
Dim CName As String
Dim CEmail As String
conEmail = New SqlConnection("Initial Catalog=EmailTest;" & _
"Data Source=localhost;Integrated Security=SSPI;")
'Create a Command object.
cmdSelect = conEmail.CreateCommand
cmdSelect.CommandText = "SELECT Name, Email FROM Customers"
'Open the connection.
Do While dtrEmail.Read()
CName = dtrEmail.GetString(0)
CEmail = dtrEmail.GetString(1)
Dim msg As New EmailMessage( _
"firstname.lastname@example.org", CName, _
"Text message.", BodyPartFormat.Plain)
Dim html As New String( _
"<html><body><em><b> This is a Test Message for u.</b></em></body></html>")
Dim smtp As New SMTP("mail.mlmp.org")
smtp.LogFile = "c:\\smtp log.txt"