Try
database.ExecCommand("SELECT_Email1", dr)
While dr.Read
'If dr.Read Then
For i As Integer = 1 To dt.Rows.Count
smtpserver.Credentials = New Net.NetworkCredential("[email protected]", "xxxxxxx")
smtpserver.Host = "smtp.live.com"
smtpserver.Port = "587"
mail = New MailMessage
mail.From = New MailAddress("[email protected]")
mail.To.Add(New MailAddress(dt.Rows(i)("emailname")))
mail.Subject = txtSuject.Text
mail.Body = txtmess.Text.Replace("<!--Link-->", "<a href=""http://localhost:65150/TEST/frmemailcancel.aspx?email=" & des.EncryptString(Me.txtto.Text) & """ target=""_blank"">")
mail.IsBodyHtml = True
smtpserver.EnableSsl = True
smtpserver.Send(mail)
Timer1.Enabled = True
ProgressBar1.Maximum = dt.Rows.Count
ProgressBar1.Increment(1)
'Thread.Sleep(50)
Application.DoEvents()
lbl1.Text = i.ToString
lbl1.Text = (i / ProgressBar1.Maximum * 100)
lbl1.Text = lbl1.Text + "%"
'If i Mod 1 = 0 Then
' Thread.Sleep(60)
'End If
lblStaus.Text = "จำนวนที่ส่ง:" & i & "ฉบับ"
Next
'End If
End While
MessageBox.Show("send mail ok")
dr.Close()
Catch ex As Exception
MsgBox("error")
End Try
Tag : .NET, Ms SQL Server 2005, Ms SQL Server 2008, VB.NET