neoseeker191 0 Light Poster

I have an ASP script that gets information from an Order Form. I have it so it displays the data. I would like to take the data displayed and send it in an email. How do I go about doing that. I've looked at tutorials on google but I dont understand how to get the displayed data into the body of the email.

Here is the orderform:

Here is the ASP Script:

<%
'*********
'Variables
'*********

	'-----------------
	'Product Variables
	'-----------------
	Dim QTY_1
	Dim QTY_2
	Dim QTY_3
	Dim QTY_4
	Dim QTY_5
	Dim QTY_6
	Dim QTY_7
	Dim QTY_8
	Dim QTY_9
	Dim QTY_10

	Dim COLOR_1
	Dim COLOR_2
	Dim COLOR_3
	Dim COLOR_4
	Dim COLOR_5
	Dim COLOR_6
	Dim COLOR_7
	Dim COLOR_8	
	
	Dim Total
	
	'--------------
	'Product Arrays
	'--------------
	
	Dim qtyArray(9)
		qtyArray(0) = QTY_1
		qtyArray(1) = QTY_2
		qtyArray(2) = QTY_3
		qtyArray(3) = QTY_4
		qtyArray(4) = QTY_5
		qtyArray(5) = QTY_6
		qtyArray(6) = QTY_7
		qtyArray(7) = QTY_8
		qtyArray(8) = QTY_9
		qtyArray(9) = QTY_10
	
	Dim colorArray(7)
		colorArray(0) = COLOR_1
		colorArray(1) = COLOR_2
		colorArray(2) = COLOR_3
		colorArray(3) = COLOR_4
		colorArray(4) = COLOR_5
		colorArray(5) = COLOR_6
		colorArray(6) = COLOR_7
		colorArray(7) = COLOR_8

		
	Dim prodArray(9)
		prodArray(0) = "TxTray Low Wing Dual Strap"
		prodArray(1) = "TxTray Thumbtray Dual Strap"
		prodArray(2) = "TxTray High Wing Dual Strap"
		prodArray(3) = "TxTray Kids Tray Dual Strap"
		prodArray(4) = "TxTray Low Wing"
		prodArray(5) = "TxTray Thumbtray"
		prodArray(6) = "TxTray High Wing"
		prodArray(7) = "TxTray Kids Tray"
		prodArray(8) = "Dual Strap Retrofit Kit"
		prodArray(9) = "Dual Strap"

	'-----------------
	'Payment Variables
	'-----------------
	
	Dim NameOnCard
	Dim PaymentMethods
	Dim CCNumber
	Dim CCExpiration
	
	'-----------------
	'Billing Variables
	'-----------------

	Dim BILLING_Name
	Dim BILLING_Company
	Dim BILLING_Address
	Dim BILLING_Address2
	Dim BILLING_City
	Dim BILLING_County
	Dim BILLING_State
	Dim BILLING_Province
	Dim BILLING_Country
	Dim BILLING_Zip
	Dim BILLING_Phone
	Dim BILLING_Extension
	Dim BILLING_Fax
	Dim BILLING_Email

	'Checkbox Variable
	Dim CheckSame

	'------------------
	'Shipping Variables
	'------------------
	
	Dim SHIPPING_Name
	Dim SHIPPING_Company
	Dim SHIPPING_Address
	Dim SHIPPING_Address2
	Dim SHIPPING_City
	Dim SHIPPING_County
	Dim SHIPPING_State
	Dim SHIPPING_Province
	Dim SHIPPING_Country
	Dim SHIPPING_Zip
	Dim SHIPPING_Phone
	Dim SHIPPING_Extension
	Dim SHIPPING_Fax
	Dim SHIPPING_Email

'If Statement Placeholders
Check = "on"
CheckValue = "No"

'********************
'Get Values From Form
'********************
	'-------------
	'Products Form
	'-------------
	QTY_1				=	Request.Form("QTY_1_TxTrayLW_DS")
	QTY_2				=	Request.Form("QTY_2_TxTrayThumb_DS")
	QTY_3				=	Request.Form("QTY_3_TxTrayHW_DS")
	QTY_4				=	Request.Form("QTY_4_TxTrayKT_DS")
	QTY_5				=	Request.Form("QTY_5_TxTrayLW")
	QTY_6				=	Request.Form("QTY_6_TxTrayThumb")
	QTY_7				=	Request.Form("QTY_7_TxTrayHW")
	QTY_8				=	Request.Form("QTY_8_TxTrayKT")
	QTY_9				=	Request.Form("QTY_9_DS_Retrofit")
	QTY_10				=	Request.Form("QTY_10_DS")
	
	COLOR_1				=	Request.Form("COLOR_1_TxTrayLW_DS")
	COLOR_2				=	Request.Form("COLOR_2_TxTrayThumb_DS")
	COLOR_3				=	Request.Form("COLOR_3_TxTrayHW_DS")
	COLOR_4				=	Request.Form("COLOR_4_TxTrayKT_DS")
	COLOR_5				=	Request.Form("COLOR_5_TxTrayLW")
	COLOR_6				=	Request.Form("COLOR_6_TxTrayThumb")
	COLOR_7				=	Request.Form("COLOR_7_TxTrayHW")
	COLOR_8				=	Request.Form("COLOR_8_TxTrayKT")
	
	Total 				=	Request.Form("editTotal")

	'--------------
	'Card Info Form
	'--------------
	
	PaymentMethods	 	= 	Request.Form("PaymentMethods")
	NameOnCard		    = 	Request.Form("PAYMENT_Name_On_Card")
	CCNumber 			=	Request.Form("CCNumber")
	CCExpiration		=	Request.Form("CCExpiration")
	
	'-----------------
	'Billing Info Form
	'-----------------
	
	BILLING_Name		=	Request.Form("BILLING_Name")
	BILLING_Company		=	Request.Form("BILLING_Company")
	BILLING_Address		=	Request.Form("BILLING_Address")
	BILLING_Address2	= 	Request.Form("BILLING_Address2")
	BILLING_City		=	Request.Form("BILLING_City")
	BILLING_County		=	Request.Form("BILLING_County")
	BILLING_State		=	Request.Form("BILLING_State")
	BILLING_Province	=	Request.Form("BILLING_Province")
	BILLING_Country		=	Request.Form("BILLING_Country")
	BILLING_Zip			=	Request.Form("BILLING_Zip")
	BILLING_Phone		=	Request.Form("BILLING_Phone")
	BILLING_Extension	=	Request.Form("BILLING_Extension")
	BILLING_Fax			=	Request.Form("BILLING_Fax")
	BILLING_Email		=	Request.Form("BILLING_Email")
	
	'Checkbox
	CheckSame			=	Request.Form("CheckSame")
	
	'Check to see if box is checked
	if  StrComp(CheckSame,Check,1)=0 then 
	CheckSame = "Yes" 
	else
	CheckSame = "No" 
	End if 
	
	'------------------
	'Shipping Info Form
	'------------------
	
	SHIPPING_Name		=	Request.Form("SHIPPING_Name")
	SHIPPING_Company	=	Request.Form("SHIPPING_Company")
	SHIPPING_Address	=	Request.Form("SHIPPING_Address")
	SHIPPING_Address2	= 	Request.Form("SHIPPING_Address2")
	SHIPPING_City		=	Request.Form("SHIPPING_City")
	SHIPPING_County		=	Request.Form("SHIPPING_County")
	SHIPPING_State		=	Request.Form("SHIPPING_State")
	SHIPPING_Province	=	Request.Form("SHIPPING_Province")
	SHIPPING_Country	=	Request.Form("SHIPPING_Country")
	SHIPPING_Zip		=	Request.Form("SHIPPING_Zip")
	SHIPPING_Phone		=	Request.Form("SHIPPING_Phone")
	SHIPPING_Extension	=	Request.Form("SHIPPING_Extension")
	SHIPPING_Fax		=	Request.Form("SHIPPING_Fax")
	SHIPPING_Email		=	Request.Form("SHIPPING_Email")
	
'**************	
'Output to User
'**************

	'Line Break For Reading Purposes
	Response.Write("---------------------------- <br />")
	
	'----------------
	'Card Info Output
	'----------------
	
	Response.Write("<b>Card Type:</b> " & PaymentMethods & "<br />")
	Response.Write("<b>Name On Card:</b> " & NameOnCard & "<br />")
	Response.Write("<b>Credit Card #:</b> " & CCNumber & "<br />")
	Response.Write("<b>Expiration (MM/YY):</b> " & CCExpiration & "<br />")
	
	'Line Break For Reading Purposes
	Response.Write("---------------------------- <br />")
	
	'-------------------
	'Billing Info Output
	'-------------------
	
	Response.Write("<b>Name:</b> " & BILLING_Name & "<br />")
	Response.Write("<b>Company:</b> " & BILLING_Company & "<br />")
	Response.Write("<b>Address:</b> " & BILLING_Address & "<br />")
	Response.Write("<b>Address (Cont):</b> " & BILLING_Address2 & "<br />")
	Response.Write("<b>City:</b> " & BILLING_City & "<br />")
	Response.Write("<b>County:</b> " & BILLING_County & "<br />")
	Response.Write("<b>State:</b> " & BILLING_State & "<br />")
	Response.Write("<b>Province:</b> " & BILLING_Province & "<br />")
	Response.Write("<b>Country:</b> " & BILLING_Country & "<br />")
	Response.Write("<b>Zipcode:</b> " & BILLING_Zip & "<br />")
	Response.Write("<b>Phone:</b> " & BILLING_Phone & "<br />")
	Response.Write("<b>Extension:</b> " & BILLING_Extension & "<br />")
	Response.Write("<b>Fax:</b> " & BILLING_Fax & "<br />")
	Response.Write("<b>Email:</b> " & BILLING_Email & "<br />")
	
	
	'Line Break For Reading Purposes
	Response.Write("---------------------------- <br />")
	
	'If box is not checked 
	if StrComp(CheckSame,CheckValue,1)=0 then
	
	'--------------------
	'Shipping Info Output
	'--------------------
	
	Response.Write("<b>Name:</b> " & SHIPPING_Name & "<br />")
	Response.Write("<b>Company:</b> " & SHIPPING_Company & "<br />")
	Response.Write("<b>Address:</b> " & SHIPPING_Address & "<br />")
	Response.Write("<b>Address (Cont):</b> " & SHIPPING_Address2 & "<br />")
	Response.Write("<b>City:</b> " & SHIPPING_City & "<br />")
	Response.Write("<b>County:</b> " & SHIPPING_County & "<br />")
	Response.Write("<b>State:</b> " & SHIPPING_State & "<br />")
	Response.Write("<b>Province:</b> " & SHIPPING_Province & "<br />")
	Response.Write("<b>Country:</b> " & SHIPPING_Country & "<br />")
	Response.Write("<b>Zipcode:</b> " & SHIPPING_Zip & "<br />")
	Response.Write("<b>Phone:</b> " & SHIPPING_Phone & "<br />")
	Response.Write("<b>Extension:</b> " & SHIPPING_Extension & "<br />")
	Response.Write("<b>Fax:</b> " & SHIPPING_Fax & "<br />")
	Response.Write("<b>Email:</b> " & SHIPPING_Email & "<br />")
	
	else
	Response.Write("<b>Shipping Same as Billing?</b> " & CheckSame & "<br />")
	End if
	
	
	
	'Line Break For Reading Purposes
	Response.Write("---------------------------- <br />")

	'Call findProduct Function (listed at bottom)
	call findproduct ()
	
	'-------------------
	'Display Final Total
	'-------------------
	
	Response.Write("<br /><b>Final Total:</b> " & Total)

'*********
'Functions	
'*********

'Looks to see if any product has a 
'quantitiy and then displays that product
function findProduct ()
	for i=0 to 9 
		if qtyArray(i) >= 1 then
			Response.Write("<br /><b>Product:</b> " & prodArray(i) & "<br />")
			Response.Write("<b>Quantity:</b> " & qtyArray(i) & "<br />" )
			Response.Write("<b>Color:</b> " & colorArray(i) & "<br />")
		end if
	next
end function
	
	
			
	
%>

I am using GoDaddy as the web server I'm not sure if that matters. Any help is appreciated, thanks.

Dani AI

Generated

— you already read the form values and print them to the page, so the easiest route is to build an email body string from those same Request.Form values and send it with CDOSYS (a CDO.Message object). Keep the email logic separate from output-to-browser (build the body first, then send). Below is a compact example that shows the pattern: iterate the Request.Form collection, redact obvious sensitive fields, and send with CDO. Adapt the field-filtering to your real names and hosting SMTP settings.

<%
Dim msg, fld, val, body
body = "New order received" & vbCrLf & vbCrLf

For Each fld In Request.Form
  If InStr(LCase(fld),"card")>0 Or InStr(LCase(fld),"cc")>0 Or InStr(LCase(fld),"cvv")>0 Then
    val = "REDACTED"
  Else
    val = Request.Form(fld)
  End If
  body = body & fld & ": " & val & vbCrLf
Next

Set msg = Server.CreateObject("CDO.Message")
msg.From = "orders@yourdomain.com"
msg.To = "orders-ops@yourdomain.com"
msg.Subject = "Order"
msg.TextBody = body

msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
msg.Configuration.Fields.Update

On Error Resume Next
msg.Send
If Err.Number <> 0 Then Response.Write("Mail error: " & Err.Description)
On Error GoTo 0

Set msg = Nothing
%>

Cautions and test tips:

  • Never email full credit-card data or CVV — mask or store only the last four digits if you need a reference. Collecting/storing card data brings PCI obligations; using a hosted payment gateway is strongly recommended.
  • Use a fixed From address (do not trust user-supplied addresses) and sanitize values to prevent header injection (strip CR/LF).
  • If mail fails: check Err.Description, confirm SMTP host/auth requirements with your host, and try the pickup method vs SMTP port. Enable visible error output while testing so you see exceptions.
  • For clearer order emails, append only the product lines (from your product loop) rather than dumping every form field.

This approach reuses the form data you already capture and keeps emailing and presentation separate, while avoiding accidental disclosure of sensitive payment details.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.