Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple CDONTS script needed 2

Status
Not open for further replies.

mattboyslim

Programmer
Joined
Aug 31, 2005
Messages
30
Location
US
Does anyone know of a very simple CDONTS (or any ASP email component at all will work) script that will simply take all form fields, and mail them the body of an email. I absolutely have no desire to manually create the standard CDONTS code to email the information, as there are over 1200 form fields. I don't care if the output is pretty or not.

Thanks in advance,
Matt
 
i am assuming that you already a CDONTS code handy and just want to grab all the form fields instead of manually typing them...you can do the following to avoid it...

Code:
For each inputField in Request.Form	
For each inputValue in Request.Form(inputField)
		response.write inputField  & " = " & inputValue & "<br>"
	Next
Next

-DNG
 
Sorry gentlemen, I could use some assistance.
I'm not getting the form fields in the email, only the first line of the "body", so you may have to point out to me where I messed it up. Here is my current code:

Code:
<%
	if Request.Form("FFSubmitted") = "yes" then
		Dim BodyString
		Dim ExcludeFields
		Dim objCDO
		Dim RedirectURL
	        Set objCDO = Server.CreateObject("CDONTS.NewMail") 
			ExcludeFields = "FFSubmitted"
			objCDO.From = "administrator@test.us"
			objCDO.To = "mtest@mtest.com" 
			objCDO.Subject = "CPC Application"	
			BodyString =  "CPC Application"
				For each inputField in Request.Form    
					For each inputValue in Request.Form(inputField)
        					response.write inputField  & " = " & inputValue & "<br>"
    					Next
				Next			
			objCDO.Body = BodyString
			objCDO.BodyFormat = 1
			objCDO.MailFormat = 1
			objCDO.Send
			Set objCDO = Nothing
			RedirectURL = "../default.asp" 
			If RedirectURL <> "" then 
				If Request.QueryString <> "" Then
  					response.redirect(RedirectURL & "?" & Request.QueryString)
				else
					response.redirect(RedirectURL)
				end If
			end if
	end if
%>
 
Code:
<%
    if Request.Form("FFSubmitted") = "yes" then
        Dim BodyString
        Dim ExcludeFields
        Dim objCDO
        Dim RedirectURL
            Set objCDO = Server.CreateObject("CDONTS.NewMail") 
            ExcludeFields = "FFSubmitted"
            objCDO.From = "administrator@test.us"
            objCDO.To = "mtest@mtest.com" 
            objCDO.Subject = "CPC Application"    
            BodyString =  "CPC Application"
                For each inputField in Request.Form    
                    For each inputValue in Request.Form(inputField)
                          [red]  BodyString=BodyString & inputField  & " = " & inputValue & "<br>"[/red]
                        Next
                Next            
            objCDO.Body = BodyString
            objCDO.BodyFormat = 1
            objCDO.MailFormat = 1
            objCDO.Send
            Set objCDO = Nothing
            RedirectURL = "../default.asp" 
            If RedirectURL <> "" then 
                If Request.QueryString <> "" Then
                      response.redirect(RedirectURL & "?" & Request.QueryString)
                else
                    response.redirect(RedirectURL)
                end If
            end if
    end if
%>

-DNG
 
or you can also use
Code:
For Each item In Request.Form
  BodyString=BodyString & item & " = " & Request.Form(item) & "<br />" & vbcrlf
Next

-DNG
 
Thanks, that was fast!
It works now, but how can I put the form fields in the order they are in on the page? Is that possible?
 
i think that code already does that...the form fields and values will be listed in the order on the form page...

-DNG
 
thanks for the info Tony...so how do you think we can order them?? number them on the form page or something like that??

-DNG
 
Have you guys figured out how we could number the form items?

Thanks,
Matt
 
ok one quick thought...may be this will work...

what you do is...number all your form elements so that it will look something like this...

<form>
<input type="textbox" name="mytext" id="[red]1[/red]">
<input type="textbox" name="mytext" id="[red]2[/red]">
<input type="textbox" name="mytext" id="[red]3[/red]">
and so on...
</form>

then you can loop them numerically using the id number...

-DNG
 
How would I loop them? Sorry, I'm no ASP pro, meaning the extent of my ASP skills involves IF/THEN statements.
 
Well the value of id could help with client-side script but I don't think it will be part of the Request on form submission so, i guess im saying that i dont think it would necessarily help with the server-side part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top