Hi there, I explain the context. I wrote a dynamic html form (with a button to add fields) because our CMS (Episerver) is too limited. Then I found an ASP function (on the web cause I have no knowkedge in ASP as a simple Intranet editor) to send data to a mail address. The sending is fine but I don't know how to put the values of the generated fields in the body since I do not know how many fields would be filled (can I use a variable?). Here are my asp function and my form fields below. Thanks in advance for any provided help! ASP Function: <% If Request.Form("btnSubmit") <> "" Then Dim Message Message = Const cdoSendUsingPort = 2 Dim oConfiguration Dim oMessage Dim oFields Set oMessage = CreateObject("CDO.Message") Set oConfiguration = CreateObject("CDO.Configuration") Set oFields = oConfiguration.Fields ' Set the CDOSYS configuration fields to use port ' 25 on the SMTP server. With oFields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") _ = cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _ = "mailhost.XXX.net" .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") _ = 10 .Update End With ' Apply the settings to the message. With oMessage Set .Configuration = oConfiguration .To = "XX.XX@XX.com" .Bcc = "" .From = request.form("txtName") .Subject = request.form("txtName") & " requests a publication" .HTMLBody = Message .Send End With ' Clean up variables. Set oMessage = Nothing Set oConfiguration = Nothing Set oFields = Nothing Response.Redirect("XXX") End If %> Code (markup): Form fields: <!-- var i=1; var input_add; function create_champ(){ var newDiv = input_add.parentNode.insertBefore( document.createElement('div'), input_add ); newDiv.id = 'champs_'+i; newDiv.innerHTML = '<table><tbody><tr><td>Title</td><td colspan="5"><input name="title_'+i+'" id="ti_'+i+'" size="40" type="text"/></td></tr><tr><td>Author</td><td colspan="5"><input name="author_'+i+'" id="au_'+i+'" size="30" type="text"/></td></tr><tr><td>Journal</td><td colspan="5"><input name="journal_'+i+'" id="so_'+i+'" size="30" type="text"/></td></tr><tr><td style="width: 65px;">Year</td><td style="width: 65px;"><input name="year_'+i+'" id="ye_'+i+'" size="4"type="text"/></td><td style="width: 65px;">Volume</td><td style="width: 65px;"><input name="volume_'+i+'" id="vol_'+i+'" size="4"type="text"/></td><td style="width: 60px;">Pages</td><td style="width: 65px;"><input name="pages_'+i+'" id="pa_'+i+'" size="4"type="text"/></td></tr></tbody></table><br>'; if(i>1) document.getElementById('input_sup').style.display = 'inline'; if(i>100) input_add.style.display = 'none'; i++; } Code (markup):
Hi, you will need to look at the Request.Form collection and iterate through it looking at the name of the object in the form. If the name of the object in the collection starts with title_ or ti_ etc then append it to the body of the email you wish to send. More info here hxxp://www.w3schools.com/ASP/coll_form.asp Best wishes MDS e.g.
I had to do a similar thing recently. I had trouble with the form not submitting the newly created textboxes by itself, so you can use javascript to manually submit the form via the query string. something like: document.getElementById("submitButton").onclick = function() { var strUrl = "Default.aspx?filled=1"; for(i=1; i<=cnt ; i++) { if(document.getElementById("champs_"+i).value == "") { window.alert("Please fill out all textboxes."); return false; } strUrl += "&c" + i + "=" + document.getElementById("champs_"+i).value; } window.location = strUrl; } Code (markup):
Then to read it you would do something like: For Each i in Request.QueryString msgBody = msgBody & i & "<br />" Next Code (markup):