Help with Email Code

D

DrNoose

Hi!

I'm working on code for a feedback form. I want the data from the user
that is taken from the form to be emailed back to me. I'm using vb with
visual studios 2005.

I have most of the code, but have some missing stuff, because I'm not
totally sure what I'm doing!

Can someone take a look at this code and tell me what I'm missing.

Thanks!

Imports System.Net.Mail
Partial Class Feedback
Inherits System.Web.UI.Page




Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnReset.Click
'Reset Fields
Me.txtName.Text = ""
Me.txtEMail.Text = ""
Me.txtCountry.Text = ""
Me.txtComments.Text = ""
Me.ddlState.SelectedValue = ""
Me.cboxSubscribe.Checked = False
Me.cblFavoriteGenre.SelectedIndex = True


End Sub

Protected Sub btnSumbit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSumbit.Click
'Get the information from the from
Dim strname As String = Me.txtName.Text
Dim stremail As String = Me.txtEMail.Text
Dim strstate As String = Me.ddlState.Text
Dim strcountry As String = Me.txtCountry.Text
Dim strgenre As String = Me.cblFavoriteGenre.Text
Dim strcomments As String = Me.txtComments.Text
Dim strsubscribe As String = Me.cboxSubscribe.Checked
Dim Subject As String =
Dim Body As String =

'Create an instance of the MailMessage class
Dim fromAdd As New MailAddress(stremail, strname)
Dim toAdd As New MailAddress("(e-mail address removed)")
Dim msg As New MailMessage(fromAdd, toAdd)
msg.Subject = "Feedback"
msg.Body = "strname"
msg.Body = msg.Body + "stremail"
msg.Body = msg.Body + "strstate"
msg.Body = msg.Body + "strcountry"
msg.Body = msg.Body + "strgenre"
msg.Body = msg.Body + "strcomments"
msg.Body = msg.Body + "strsubscribe"
Dim client As New SmtpClient("localhost")
client.Send(msg)

End Sub


End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top