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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFMAIL and Sessions

Status
Not open for further replies.

eugeniana

Programmer
Jun 16, 2004
15
US
I have an issue I've been struggling with:

Our website is set up so that a customer starts a session by entering their zip code and account number. The variables are collected as they order. At the end of the order, the site is supposed to email them a copy of the invoice for their order... again using the session variables, and this time using an include. On testing I get back this:

A CFOUTPUT tag is nested in a CFMAIL tag with no GROUP= or QUERY= attributes. This is not allowed. Nesting these tags implies that you want to used grouped processing. However, the outer tag does not specify a query to look over a group to process.

Here is the code:

<cfoutput>
<cfmail to="orderdesk@millerdavis.com, annam@millerdavis.com" from="orderdesk@millerdavis.com" cc="#Session.email#" subject="Client Web Order" type="html">
<cfoutput>
<table border="1" width="400" cellspacing="0" cellpadding="3">
<tr>
<td colspan="3">
#Session.OrderName#<br>
#Session.ClientName# <br>
#Session.ClientAddress1# <br>
#Session.ClientAddress2# <br>
#Session.ClientCity#, #Session.ClientState# #Session.ClientZip# <br>
#Session.ClientPhone#<P>
</td>
<td>Account Number: #Session.ClientMDCID#</td>
<td valign="top">#DateFormat(now())#</td>
</tr>
<tr>
<td><b>Form Number</b></td>
<td><b>Item</b></td>
<td><b>Quantity</b></td>
<td><b>Price</b></td>
<td><b>Total</b></td>
</tr>
<!--- Intialize GrandTotal at 0--->
<cfset GrandTotal = 0>
<!--- Start loop ------------------------------------------------------------ --->
<!--- Loop through each item in Session.StoreItems list and add it and quantity to lineItem table--->
<!--- Get legnth of list --->
<cfloop from="1" to="#ListLen(Session.StoreItems)#" index="i">
<!--- set productID i to ProID --->
<cfset ProID =#ListGetAt(Session.StoreItems, i)#>

<!--- set quantity i to theQuant --->
<cfset theQuant = #ListGetAt(Session.StoreQuantities, i)#>

<!--- query the product table to get price of item i --->
<CFQUERY NAME="getPrice" DATASOURCE="MillerDavis">
SELECT PriceType, Price as pPrice, Description, FormNo
FROM MDForms
Where FormID = #ProID#
</CFQUERY>

<!--- set price to thePrice and get linetotal> May need to update this for account holders --->
<cfswitch expression=#getPrice.PriceType#>
<cfcase value="1">
<cfif theQuant gt 11>
<cfset thePrice = 1.11>
<cfelse>
<cfset thePrice = 1.55>
</cfif>
</cfcase>
<cfcase value="2">
<cfif theQuant gt 11>
<cfset thePrice = 1.89>
<cfelse>
<cfset thePrice = 2.49>
</cfif>
</cfcase>
<cfdefaultcase>
<cfset thePrice = #getprice.pPrice#>
</cfdefaultcase>
</cfswitch>

<!--- Set linetotal to price of product times value i of Session.StoreQuantites --->
<cfset lineTotal = thePrice * theQuant>
<!--- Set grandTotal to grandTotal plus lineTotal of item i of Session.StoreItems --->
<cfset GrandTotal= GrandTotal + lineTotal>
<tr>
<td>#getprice.FormNo# </td>
<td>#getprice.description# </td>
<td>#theQuant# </td>
<td>#DollarFormat(thePrice)#</td>
<td>#DollarFormat(lineTotal)#</td>
</tr>

</cfloop>
<tr>
<td colspan="4"><b>Subtotal</b> </td>
<td>#DollarFormat(GrandTotal)#</td>
</tr>
<cfif Session.ClientState eq "MN">
<cfset taxrate = 0.07>
<cfelse>
<cfset taxrate = 0>
</cfif>
<cfset shipping = 5>
<cfset Grandtotal = Grandtotal + shipping>
<cfset tax = GrandTotal * taxrate>
<cfset grandTotal = grandTotal + tax>
<tr>
<td colspan="4"><b>Shipping</b> </td>
<td>#DollarFormat(shipping)# *</td>
</tr>
<tr>
<td colspan="4"><b>Tax</b> </td>
<td>#DollarFormat(tax)#</td>
</tr>
<tr>
<td colspan="4"><b>Grand Total</b></td>
<td>#DollarFormat(grandTotal)#</td>
</tr>
<TR>
<TD colspan="5"><font size="-2">* When a large number of forms are ordered (over 100), shipping may be more than $5.00. If this is the case, the receipt that ships with the order will reflect the new shipping amount.</font></td>
</tr>
</table>
</cfmail>
</cfoutput>

Help anyone?
 
Remove your <cfoutput> tags. You don't need them with cfmail.



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
I removed them... but still no dice. I still get the same error. Is it because it's in an include?
 
You can't have a cfoutput tag surrounding or inside of a cfmail tag unless you use grouping in your output, that's what the error is telling you. Make sure there are no cfoutput tags around or in your cfmail tag. If you're using it as an include, make sure your cfinclude tag isn't inside cfoutputs.





Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
That's just it... all the cfoutput tags are gone now and it still doesn't work.
 
And you're still getting the "A CFOUTPUT tag is nested in a CFMAIL tag" error message?



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
Please post your revised code..

btw if you wrap your code with [ code] and [ /code] (without the spaces.. you get a much cleaner easier to read set of code.

Here's the above paragraph in that..

Code:
btw if you wrap your code with [ code] and [ /code] (without the spaces.. you get a much cleaner easier to read set of code.

Much nicer.. but it works best for code (as should be obvious), not text.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Okay... Here's the whole of the code for the receipt... again this is an include:

Code:
<cfoutput>
	<table border="1" width="400" cellspacing="0" cellpadding="3">
	<tr>
		<td colspan="3">
			#Session.OrderName#<br>
			#Session.ClientName# <br> 
			#Session.ClientAddress1# <br>
			#Session.ClientAddress2# <br>
			#Session.ClientCity#, #Session.ClientState# #Session.ClientZip# <br>
			#Session.ClientPhone#<P>
		</td>
		<td>Account Number: #Session.ClientMDCID#</td>
		<td valign="top">#DateFormat(now())#</td>
	</tr>
	<tr>
		<td><b>Form Number</b></td>
		<td><b>Item</b></td>
		<td><b>Quantity</b></td>
		<td><b>Price</b></td>
		<td><b>Total</b></td>
	</tr>
	<!--- Intialize GrandTotal at 0--->
	<cfset GrandTotal = 0>
	<!--- Start loop ------------------------------------------------------------ --->
		<!--- Loop through each item in Session.StoreItems list and add it and quantity to lineItem table--->
		<!--- Get legnth of list --->
		<cfloop from="1" to="#ListLen(Session.StoreItems)#" index="i">
		<!--- set productID i to ProID --->
		<cfset ProID =#ListGetAt(Session.StoreItems, i)#>
		
		<!--- set quantity i to theQuant --->
		<cfset theQuant = #ListGetAt(Session.StoreQuantities, i)#>
		
		<!--- query the product table to get price of item i --->
		<CFQUERY NAME="getPrice" DATASOURCE="MillerDavis">
		SELECT      PriceType, Price as pPrice, Description, FormNo
		FROM         MDForms 
		Where FormID = #ProID#
		</CFQUERY>
		
		<!--- set price to thePrice and get linetotal> May need to update this for account holders --->
		<cfswitch expression=#getPrice.PriceType#> 
  			<cfcase value="1"> 
   		 	 <cfif theQuant gt 11>
			 	<cfset thePrice = 1.11> 
			<cfelse>
			 	<cfset thePrice = 1.55> 
			 </cfif>
  			</cfcase> 
  			<cfcase value="2"> 
   		 	  <cfif theQuant gt 11>
			 	<cfset thePrice = 1.89> 
			<cfelse>
			 	<cfset thePrice = 2.49> 
			 </cfif>
  			</cfcase> 
  			<cfdefaultcase> 
    		<cfset thePrice = #getprice.pPrice#>
  			</cfdefaultcase> 
		</cfswitch> 

		<!--- Set linetotal to price of product times value i of Session.StoreQuantites --->
		<cfset lineTotal = thePrice * theQuant>
		<!--- Set grandTotal to grandTotal plus lineTotal of item i of Session.StoreItems --->
		<cfset GrandTotal= GrandTotal + lineTotal>
		<tr>
			<td>#getprice.FormNo# </td>
			<td>#getprice.description# </td>
			<td>#theQuant#			   </td>
			<td>#DollarFormat(thePrice)#</td>
			<td>#DollarFormat(lineTotal)#</td>
		</tr>
		
		</cfloop>
		<tr>
			<td colspan="4"><b>Subtotal</b>     </td>
			<td>#DollarFormat(GrandTotal)#</td>
		</tr>
		<cfif Session.ClientState eq "MN">
			<cfset taxrate = 0.07>
		<cfelse>
			<cfset taxrate = 0>	
		</cfif>
		<cfset shipping = 5>
		<cfset Grandtotal = Grandtotal + shipping>
		<cfset tax = GrandTotal * taxrate>
		<cfset grandTotal = grandTotal  + tax>
		<tr>
			<td colspan="4"><b>Shipping</b>     </td>
			<td>#DollarFormat(shipping)# *</td>
		</tr>
		<tr>
			<td colspan="4"><b>Tax</b>     </td>
			<td>#DollarFormat(tax)#</td>
		</tr>
		<tr>
			<td colspan="4"><b>Grand Total</b></td>
			<td>#DollarFormat(grandTotal)#</td>
		</tr>
		<TR>
			<TD colspan="5"><font size="-2">* When a large number of forms are ordered (over 100), shipping may be more than $5.00. If this is the case, the receipt that ships with the order will reflect the new shipping amount.</font></td>
		</tr>
	</table>
	</cfoutput>
	<cfmail to="place@place.com, place@place.com" from="place@place.com" cc="#Session.email#" subject="Client Web Order" type="html">
	<table border="1" width="400" cellspacing="0" cellpadding="3">
	<tr>
		<td colspan="3">
			#Session.OrderName#<br>
			#Session.ClientName# <br> 
			#Session.ClientAddress1# <br>
			#Session.ClientAddress2# <br>
			#Session.ClientCity#, #Session.ClientState# #Session.ClientZip# <br>
			#Session.ClientPhone#<P>
		</td>
		<td>Account Number: #Session.ClientMDCID#</td>
		<td valign="top">#DateFormat(now())#</td>
	</tr>
	<tr>
		<td><b>Form Number</b></td>
		<td><b>Item</b></td>
		<td><b>Quantity</b></td>
		<td><b>Price</b></td>
		<td><b>Total</b></td>
	</tr>
	<!--- Intialize GrandTotal at 0--->
	<cfset GrandTotal = 0>
	<!--- Start loop ------------------------------------------------------------ --->
		<!--- Loop through each item in Session.StoreItems list and add it and quantity to lineItem table--->
		<!--- Get legnth of list --->
		<cfloop from="1" to="#ListLen(Session.StoreItems)#" index="i">
		<!--- set productID i to ProID --->
		<cfset ProID =#ListGetAt(Session.StoreItems, i)#>
		
		<!--- set quantity i to theQuant --->
		<cfset theQuant = #ListGetAt(Session.StoreQuantities, i)#>
		
		<!--- query the product table to get price of item i --->
		<CFQUERY NAME="getPrice" DATASOURCE="MillerDavis">
		SELECT      PriceType, Price as pPrice, Description, FormNo
		FROM         MDForms 
		Where FormID = #ProID#
		</CFQUERY>
		
		<!--- set price to thePrice and get linetotal> May need to update this for account holders --->
		<cfswitch expression=#getPrice.PriceType#> 
  			<cfcase value="1"> 
   		 	 <cfif theQuant gt 11>
			 	<cfset thePrice = 1.11> 
			<cfelse>
			 	<cfset thePrice = 1.55> 
			 </cfif>
  			</cfcase> 
  			<cfcase value="2"> 
   		 	  <cfif theQuant gt 11>
			 	<cfset thePrice = 1.89> 
			<cfelse>
			 	<cfset thePrice = 2.49> 
			 </cfif>
  			</cfcase> 
  			<cfdefaultcase> 
    		<cfset thePrice = #getprice.pPrice#>
  			</cfdefaultcase> 
		</cfswitch> 

		<!--- Set linetotal to price of product times value i of Session.StoreQuantites --->
		<cfset lineTotal = thePrice * theQuant>
		<!--- Set grandTotal to grandTotal plus lineTotal of item i of Session.StoreItems --->
		<cfset GrandTotal= GrandTotal + lineTotal>
		<tr>
			<td>#getprice.FormNo# </td>
			<td>#getprice.description# </td>
			<td>#theQuant#			   </td>
			<td>#DollarFormat(thePrice)#</td>
			<td>#DollarFormat(lineTotal)#</td>
		</tr>
		
		</cfloop>
		<tr>
			<td colspan="4"><b>Subtotal</b>     </td>
			<td>#DollarFormat(GrandTotal)#</td>
		</tr>
		<cfif Session.ClientState eq "MN">
			<cfset taxrate = 0.07>
		<cfelse>
			<cfset taxrate = 0>	
		</cfif>
		<cfset shipping = 5>
		<cfset Grandtotal = Grandtotal + shipping>
		<cfset tax = GrandTotal * taxrate>
		<cfset grandTotal = grandTotal  + tax>
		<tr>
			<td colspan="4"><b>Shipping</b>     </td>
			<td>#DollarFormat(shipping)# *</td>
		</tr>
		<tr>
			<td colspan="4"><b>Tax</b>     </td>
			<td>#DollarFormat(tax)#</td>
		</tr>
		<tr>
			<td colspan="4"><b>Grand Total</b></td>
			<td>#DollarFormat(grandTotal)#</td>
		</tr>
		<TR>
			<TD colspan="5"><font size="-2">* When a large number of forms are ordered (over 100), shipping may be more than $5.00. If this is the case, the receipt that ships with the order will reflect the new shipping amount.</font></td>
		</tr>
	</table>
	</cfmail>

I'm still getting that error no matter what I've tried. I'm at the end of my rope.

Thanks!
 
Try taking the cfoutputs out of the included page..

It might not output but at least you shouldn't get an error.. we'll work from there.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
That certainly got rid of the error. But now no variables are coming through either.
 
Your last post made no sense.. "It did email you the properly"

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
It's fixed!!! Yay!! Thank both of you for your help... I just moved the code that needed to be outputed to the main page and kept only the cfmail in the include page. Now it works like a dream.

Thanks again! It was really appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top