hi all,
I am working on this feedback form and I am entering the data to access database and then also send the result by e-mail. This way, if the email gets lost, there is still a record of the Feedback.
I think i can enter the data with out any problem but sending e-mail part is giving me a headache and I really appreciate one of you take a look at my code throw me some ideas. thank you
Imports System.Data.OleDb
Imports System.Net.Mail
Partial Class FeedBack
Inherits System.Web.UI.Page
Sub doInsert(ByVal Source As Object, ByVal E As EventArgs)
Dim conFeedBack As OleDbConnection
conFeedBack = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\FeedBack.mdb")
Dim MySQL As String = "Insert into feedback (CompanyName,ContactPerson,Address1,Address2,City, State,ZipCode,PhoneNumber, Email, Fax,Comment) " & _
"Values (@Office, @person,@Address1,@Address2,@City,@State,@Zip,@Phone,@Email,@Fax,@Comment)"
Dim Cmd As New OleDbCommand(MySQL, conFeedBack)
With Cmd.Parameters
.Add(New OleDbParameter("@Office", txtOffice.Text))
.Add(New OleDbParameter("@Person", txtPerson.Text))
.Add(New OleDbParameter("@Address1", txtAddress1.Text))
.Add(New OleDbParameter("@Address2", txtAddress2.Text))
.Add(New OleDbParameter("@City", txtCity.Text))
.Add(New OleDbParameter("@State", dpState.Text))
.Add(New OleDbParameter("@Zip", txtZip.Text))
.Add(New OleDbParameter("@Phone", txtPhone.Text))
.Add(New OleDbParameter("@Email", txtEmail.Text))
.Add(New OleDbParameter("@Fax", txtFax.Text))
.Add(New OleDbParameter("@Comment", txtComment.Text))
'.Add(New OleDbParameter("@dtEntered", DateTime.Now()))
End With
conFeedBack.Open()
cmd.ExecuteNonQuery()
lblFeed.Text = "Your inormation has been successfully received." & _
"We will get back to you as soon as possible"
conFeedBack.Close()
End Sub
Sub doEmail()
Dim sMsg As String
Dim sBody As String
sMsg = "Feedback has been sent to you." & vbcrlf & "The results are as follows:" & vbcrlf
sMsg += "Company Name : " & txtOffice.Text & vbCrLf
sMsg += "Contact Person : " & txtPerson.Text & vbCrLf
sMsg += "Address1 : " & txtAddress1.Text & vbCrLf
sMsg += "Address2 : " & txtAddress2.Text & vbCrLf
sMsg += "City : " & txtCity.Text & vbCrLf
sMsg += "State : " & dpState.Text & vbCrLf
sMsg += "Zip Code : " & txtZip.Text & vbCrLf
sMsg += "Phone Number : " & txtPhone.Text & vbCrLf
sMsg += "Fax : " & txtFax.Text & vbCrLf
sMsg += "E-mail : " & txtEmail.Text & vbCrLf
----------I am getting error msg below this line
Dim objEmail As New MailMessage
objEmail.To=Bid.Letting@dot.state.mn.us
objEmail.From = txtEmail.Text
objEmail.Subject = "You have Feedback"
objEmail.Body = sMsg
objEmail.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = "mail.Wherever.com"
SmtpMail.Send(objEmail)
End Sub
End Class
I am working on this feedback form and I am entering the data to access database and then also send the result by e-mail. This way, if the email gets lost, there is still a record of the Feedback.
I think i can enter the data with out any problem but sending e-mail part is giving me a headache and I really appreciate one of you take a look at my code throw me some ideas. thank you
Imports System.Data.OleDb
Imports System.Net.Mail
Partial Class FeedBack
Inherits System.Web.UI.Page
Sub doInsert(ByVal Source As Object, ByVal E As EventArgs)
Dim conFeedBack As OleDbConnection
conFeedBack = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\FeedBack.mdb")
Dim MySQL As String = "Insert into feedback (CompanyName,ContactPerson,Address1,Address2,City, State,ZipCode,PhoneNumber, Email, Fax,Comment) " & _
"Values (@Office, @person,@Address1,@Address2,@City,@State,@Zip,@Phone,@Email,@Fax,@Comment)"
Dim Cmd As New OleDbCommand(MySQL, conFeedBack)
With Cmd.Parameters
.Add(New OleDbParameter("@Office", txtOffice.Text))
.Add(New OleDbParameter("@Person", txtPerson.Text))
.Add(New OleDbParameter("@Address1", txtAddress1.Text))
.Add(New OleDbParameter("@Address2", txtAddress2.Text))
.Add(New OleDbParameter("@City", txtCity.Text))
.Add(New OleDbParameter("@State", dpState.Text))
.Add(New OleDbParameter("@Zip", txtZip.Text))
.Add(New OleDbParameter("@Phone", txtPhone.Text))
.Add(New OleDbParameter("@Email", txtEmail.Text))
.Add(New OleDbParameter("@Fax", txtFax.Text))
.Add(New OleDbParameter("@Comment", txtComment.Text))
'.Add(New OleDbParameter("@dtEntered", DateTime.Now()))
End With
conFeedBack.Open()
cmd.ExecuteNonQuery()
lblFeed.Text = "Your inormation has been successfully received." & _
"We will get back to you as soon as possible"
conFeedBack.Close()
End Sub
Sub doEmail()
Dim sMsg As String
Dim sBody As String
sMsg = "Feedback has been sent to you." & vbcrlf & "The results are as follows:" & vbcrlf
sMsg += "Company Name : " & txtOffice.Text & vbCrLf
sMsg += "Contact Person : " & txtPerson.Text & vbCrLf
sMsg += "Address1 : " & txtAddress1.Text & vbCrLf
sMsg += "Address2 : " & txtAddress2.Text & vbCrLf
sMsg += "City : " & txtCity.Text & vbCrLf
sMsg += "State : " & dpState.Text & vbCrLf
sMsg += "Zip Code : " & txtZip.Text & vbCrLf
sMsg += "Phone Number : " & txtPhone.Text & vbCrLf
sMsg += "Fax : " & txtFax.Text & vbCrLf
sMsg += "E-mail : " & txtEmail.Text & vbCrLf
----------I am getting error msg below this line
Dim objEmail As New MailMessage
objEmail.To=Bid.Letting@dot.state.mn.us
objEmail.From = txtEmail.Text
objEmail.Subject = "You have Feedback"
objEmail.Body = sMsg
objEmail.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = "mail.Wherever.com"
SmtpMail.Send(objEmail)
End Sub
End Class