I am looking for a way to email all the values entered by a user into a form. Does this exist in asp.net ?
here is my email code:
Dim messagemain As String = emailbody
Dim message As New MailMessage()
message.IsBodyHtml = True
message.From = New MailAddress("foo@foo.com")
message.To.Add(New MailAddress("foo@foo.com"))
message.Subject = ("Response from form")
message.Body = (messagemain)
Dim client As New SmtpClient()
client.Host = "email.foo.foo"
client.Send(message)
I usually go through manually and ad all the necessaries to the emailbody var then send, but this form has over 200 fields.
Thanks.
You may try too looping over the
Controlscollection of the page and if you find a textbox add its value to the mail body:Remark: This will work only if the text boxes are directly placed on the page and not inside some other containers such as panels, … In order to take this into account you could write a recursive function that visits all the controls.