HOME > .NET Framework > Forum > เออเลอร์ตรงอีเมลครับ ช่วยดูให้หน่อย ไม่รู้เป็นอะไรครับ ตรงประกาศตัวแปร Dim myMail As New MailMessage() แล้ว MailMessage ขึ้นข้อความสีฟ้า
เออเลอร์ตรงอีเมลครับ ช่วยดูให้หน่อย ไม่รู้เป็นอะไรครับ ตรงประกาศตัวแปร Dim myMail As New MailMessage() แล้ว MailMessage ขึ้นข้อความสีฟ้า
Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnReset.Click
Dim objConn As SqlConnection
Dim strConnString As String
Dim strSQL As StringBuilder
Dim objCmd As SqlCommand
Dim dtReader As SqlDataReader
'*** Open Connection ***'
strConnString = "Data Source=WIN-6UUC8440UAQ\EXPRESS;Initial Catalog=Computer;Integrated Security=True;"
objConn = New SqlConnection
objConn.ConnectionString = strConnString
objConn.Open()
'*** Get Data ***'
strSQL = New StringBuilder
strSQL.Append(" SELECT * FROM Member ")
strSQL.Append(" WHERE UserName = @sUserName ")
strSQL.Append(" OR Email = @sEmail ")
objCmd = New SqlCommand(strSQL.ToString(), objConn)
objCmd.Parameters.Add("@sUserName", SqlDbType.VarChar).Value = Me.txtUsername.Text
objCmd.Parameters.Add("@sEmail", SqlDbType.VarChar).Value = Me.txtEmail.Text
dtReader = objCmd.ExecuteReader()
If Not dtReader.HasRows Then
Me.lblStatus.ForeColor = Drawing.Color.Red
Me.lblStatus.Text = "Username or Password wrong!"
Else
dtReader.Read()
Dim myMail As New MailMessage()
myMail.To = dtReader("Email").ToString()
myMail.From = "[email protected]"
myMail.Subject = "Account UserName & Password"
myMail.BodyFormat = MailFormat.Html
myMail.Body = "UserName = " & dtReader("UserName").ToString() & "" & _
"<br> Password = " & dtReader("Password").ToString()
SmtpMail.SmtpServer = "172.16.167.42" '*** Mail Server ***'
SmtpMail.Send(myMail)
myMail = Nothing
Me.lblMessage.Text = "Your password has been send to mail (" & dtReader("Email").ToString() & ")"
Me.pnlReset.Visible = False
Me.pnlFinish.Visible = True
End If
dtReader.Close()
objConn.Close()
objConn = Nothing
End Sub
End Class