Try
'Me.Label5.Text = "sending mail"
'Timer1.Start()
'Timer1.Enabled = True
Dim smtpserver As New SmtpClient
smtpserver.Credentials = New Net.NetworkCredential("[email protected]", "xxxxxx")
smtpserver.Host = ComboBox1.Text
smtpserver.Port = "587"
Dim des As New TohomeCenter.EmCRMLib.Encryption
Dim mail As New MailMessage
Dim i As Integer
For i = 0 To dt.Rows.Count - 1
mail = New MailMessage
mail.From = New MailAddress("[email protected]")
mail.To.Add(New MailAddress(dt.Rows(i)("emailname")))
Timer1.Enabled = True
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)
'Dim msg As String
'Dim title As String
'Dim style As MsgBoxStyle
'Dim response As MsgBoxResult
'msg = "Your Mail Has Been Sent"
'style = MsgBoxStyle.OkOnly
'title = "Mail Sent Conformation"
'response = MsgBox(msg, style, title)
'If response = MsgBoxResult.Ok Then
' Me.Label1.Text = " "
' Timer1.Stop()
' Timer1.Enabled = False
'End If
'MessageBox.Show("send mail ok")
MsgBox("ทำการส่ง E-mail เรียบร้อย", MsgBoxStyle.Information, "ขอบคุณ")
Next
Catch ex As Exception
MsgBox("error")
End Try
End Sub