Reputation: 1904
May someone please assist me in correcting this error that occurs when I try to send an email from the contact us page of my website
My code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As New MailMessage()
msg.From = New MailAddress(email.Text)
msg.[To].Add(New MailAddress("[email protected]"))
msg.Subject = subject.Text
msg.Body = Message.Text
'Try
' SmtpMail.SmtpServer = " smtp server name or address "
' SmtpMail.Send(msg)
'Catch ex As HttpException
' Response.Write("Error: " + ex.ToString())
'Catch ex As Exception
' Response.Write("Error: " + ex.ToString())
'End Try
Dim smtp As New SmtpClient("milcoxmanor.com", 25)
smtp.Credentials = New NetworkCredential("[email protected]", "12345")
smtp.Send(msg)
End Sub
Protected Sub ClearFields()
fname.Text = " "
lname.Text = " "
email.Text = " "
subject.Text = " "
message.Text = " "
End Sub
End Class
Upvotes: 0
Views: 159
Reputation: 3294
Based on the error, you're probably missing:
Imports System.Net.Mail
at the top of the file
Upvotes: 1