How to create an asp.net email form?

  • Thread starter Thread starter lbsoccerboy23
  • Start date Start date
L

lbsoccerboy23

Guest
I am trying to create this form for a website, but I can't get it to send me the final email. I am not getting any errors, I'm just not getting the email containing the information in the form. Does anyone have any suggestions? Here is the code I have right now.

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs )

If IsPostBack Then

Dim sc As SmtpClient = New SmtpClient("mail.yorkeengr.com")
Dim sb As StringBuilder = New StringBuilder()
Dim msg As MailMessage = Nothing
Dim Credentials2 As New NetworkCredential("", "", "")
Credentials2.Domain = "[domain]"
Credentials2.UserName = "[login]"
Credentials2.Password = "[password]"

sb.Append("Name: " + name.Text + vbCrLf)
sb.Append("Email: " + email.Text + vbCrLf)
sb.Append("Company: " + company.Text + vbCrLf)
sb.Append("Phone: " + phone.Text + vbCrLf)
sb.Append("Address: " + address.Text + vbCrLf)
sb.Append("Comments: " + comments.Text + vbCrLf)

Try
msg = New MailMessage(name.Text, _
"", "Message from Web Site", _
sb.ToString())

sc.UseDefaultCredentials = False
sc.Credentials = Credentials2

sc.Send(msg)

Catch ex As Exception

' something bad happened
Response.Write("An error has occured. Please try again.")

Finally

If Not msg Is Nothing Then msg.Dispose()

End Try

End If

End Sub

</script>

Thanks.
Oh, and yes, I know that i don't have my particular user information in there...I don't need everyone online to know that.
More particularly...that is the script that I have. I have the design working great.
 
Back
Top