我正在嘗試提供反饋表單,但從未做過此操作。我找到了一個在VB中解釋它的教程,但即使代碼適用於他,它似乎也不適用於我。失敗後,我嘗試了另一個教程,仍然沒有去!但由於第一個看起來更簡單,我決定再試一次。有些人可以幫我解釋我做錯了什麼嗎?反饋表單會產生錯誤
我有4個文本框Name
,Email
,Telephone
和Comments
的錯誤似乎是
Dim message As MailMessage = New MailMessage(from, "[email protected]", "feedback", body)
錯誤:指定的字符串不是一個電子郵件地址所要求的形式。
教程:[How Do I:] Create a "Contact Us" Page?
Protected Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
SendMail(txtName.Text, txtEmail.Text)
SendMail(txtTel.Text, txtComments.Text)
End Sub
Private Sub SendMail(ByVal from As String, ByVal body As String)
Dim mailServerName As String = "SMTP.bulldogbroadband.co.za"
Dim message As MailMessage = New MailMessage(from, "[email protected]", "feedback", body)
Dim mailClient As SmtpClient = New SmtpClient
mailClient.Host = mailServerName
mailClient.Send(message)
message.Dispose()
End Sub