I am trying to convert a checkbox into a string that can be emailed using my asp.net code. The code below is rewriting the Jquery script into ASP.net which works fine. However, as outlined below in the code, the convert to string function is converting textfields and checkboxes. The form worked fine until I added the checkboxes and is not converting the checkboxes. Is there another function to convert the checkboxes to string so that they can be emailed?
Case 4 Contact Form
Response.Write(sendMailSE(Convert.ToString(Request.Form("name")), Convert.ToString(Request.Form("field1")), Convert.ToString(Request.Form("field2")), Convert.ToString(Request.Form("field3")), Convert.ToString(Request.Form("field4")), Convert.ToString(Request.Form("checkbox1")), Convert.ToString(Request.Form("checkbox2")), Convert.ToString(Request.Form("checkbox3")), Convert.ToString(Request.Form("comments"))))
Public Function sendMailSE(ByVal field1, ByVal field2, ByVal field3, ByVal field4, ByVal checkbox1, ByVal checkbox2, ByVal checkbox3, ByVal comments) As String
Try
Const ToAddress As String = "jdoe@abcd.com"
'(1) Create the MailMessage instance
Dim mm As New System.Net.Mail.MailMessage("jdoe@abcd.com", ToAddress)
'create cocantenated string for body of message
Dim sb As StringBuilder = New StringBuilder()
'(2) Assign the MailMessage's properties
mm.Subject = "Contact Us: "
sb.Append("Contact Us: " + vbCrLf)
sb.Append("----------------------------------" + vbCrLf)
sb.Append("Date " + DateTime.Now() + vbCrLf)
sb.Append("Field1: " + field1 + vbCrLf)
sb.Append("Field2:" + field2 + vbCrLf)
sb.Append("Field3: " + field3 + vbCrLf)
sb.Append("Field4: " + field4 + vbCrLf)
sb.Append("Checkbox1 " + IIf(checkbox1, "Yes", "No") + vbCrLf)
sb.Append("Checkbox2 " + IIf(checkbox2, "Yes", "No") + vbCrLf)
sb.Append("Checkbox3 " + IIf(checkbox3, "Yes", "No") + vbCrLf)
sb.Append("Comments: " + comments + vbCrLf)
I have removed the code below this line
Aucun commentaire:
Enregistrer un commentaire