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

Need URGENT help with all items not showing in email

Status
Not open for further replies.

humbletechie

IS-IT--Management
May 3, 2001
33
0
0
US
The code that sends the email, only list the first item in the cart, the cart items are pulled from an access database. The items are all in the database but only the first item shows in the email that is sent. Below is the code, can someome please help? Thanks..

<% option explicit %>
<% response.buffer=true %>
<!--#include file=&quot;cart_lib.asp&quot;-->
<%
sub sendMail(RecipientAddr, From, Subject, Message) 'As String
dim Mail
Set Mail = Server.CreateObject(&quot;Persits.MailSender&quot;)

Mail.Host = &quot;mail.luggagebase.com&quot; ' Specify a valid SMTP server
Mail.From = From ' Specify sender's address, this must be an 'AveHost.com hosted domain name for the email form to fire.
Mail.FromName = &quot;LuggageBase.com Service&quot; ' Specify sender's name

Mail.AddAddress RecipientAddr ' Name is optional
Mail.AddReplyTo From

Mail.Subject = Subject
Mail.Body = Message

On Error Resume Next
Mail.Send
If Err <> 0 Then
Response.Write &quot;Error encountered: &quot; & Err.Description
End If


end sub

dim str strDBRoot, strDBName,strConnectionString
'Get the root str = server.mappath(&quot;/&quot;)
strDBRoot = str & &quot;\..\data\luggagebase\&quot;
strDBName = &quot;luggage.mdb&quot;
strConnectionString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & strDBRoot & strDBName
DIM oConn,rs,sql
set oConn= Server.CreateObject(&quot;ADODB.connection&quot;)
set rs=Server.CreateObject(&quot;ADODB.recordset&quot;)
oConn.ConnectionString = strConnectionString
oConn.Open

DIM custid
DIM bfirstname,blastname,bcompany,baddr1,baddr2,bcity,bstate,bzip,bphone,bemail
DIM sfirstname,slastname,scompany,saddr1,saddr2,scity,sstate,szip,sphone
DIM ccnum,cctype,ccmonth,ccyear
DIM TotalRetail,TotalShipping,TotalTax,TotalOrder

custid = CheckForCustID()

bfirstname = trim(request.form(&quot;bfirstname&quot;))
blastname = trim(request.form(&quot;blastname&quot;))
bcompany = trim(request.form(&quot;bcompany&quot;))
baddr1 = trim(request.form(&quot;baddr1&quot;))
baddr2 = trim(request.form(&quot;baddr2&quot;))
bcity = trim(request.form(&quot;bcity&quot;))
bstate = trim(request.form(&quot;bstate&quot;))
bzip = trim(request.form(&quot;bzip&quot;))
bphone = trim(request.form(&quot;bphone&quot;))
bemail = trim(request.form(&quot;bemail&quot;))

sfirstname = trim(request.form(&quot;sfirstname&quot;))
slastname = trim(request.form(&quot;slastname&quot;))
scompany = trim(request.form(&quot;scompany&quot;))
saddr1 = trim(request.form(&quot;saddr1&quot;))
saddr2 = trim(request.form(&quot;saddr2&quot;))
scity = trim(request.form(&quot;scity&quot;))
sstate = trim(request.form(&quot;sstate&quot;))
szip = trim(request.form(&quot;szip&quot;))
sphone = trim(request.form(&quot;sphone&quot;))

cctype = trim(request.form(&quot;cardtype&quot;))
ccnum =trim(request.form(&quot;ccnum&quot;))
ccmonth =trim(request.form(&quot;ccmonth&quot;))
ccyear =trim(request.form(&quot;ccyear&quot;))

TotalRetail = trim(request.form(&quot;totalretail&quot;))
TotalShipping = trim(request.form(&quot;totalshipping&quot;))
TotalTax = trim(request.form(&quot;totaltax&quot;))
TotalOrder = trim(request.form(&quot;totalorder&quot;))

'first we update billing info
sql = &quot;update customers set &quot;
sql = sql & &quot; [firstname]='&quot;&bfirstname&&quot;', &quot;
sql = sql & &quot; [lastname]='&quot;&blastname&&quot;', &quot;
sql = sql & &quot; [company]='&quot;&bcompany&&quot;', &quot;
sql = sql & &quot; [addr1]='&quot;&baddr1&&quot;', &quot;
sql = sql & &quot; [addr2]='&quot;&baddr2&&quot;', &quot;
sql = sql & &quot; [city]='&quot;&bcity&&quot;', &quot;
sql = sql & &quot; [state]='&quot;&bstate&&quot;', &quot;
sql = sql & &quot; [zip]='&quot;&bzip&&quot;', &quot;
sql = sql & &quot; [phone]='&quot;&bphone&&quot;' where [id]= &quot;&custid&&quot; ;&quot;

'response.write &quot;<br>&quot;&sql&&quot;<br>&quot;

oConn.execute(sql)

dim shiptoid
shiptoid = 0
''if we have shipping info create shipto
if(sfirstname <> &quot;&quot;) then
sql = &quot;INSERT INTO cart_shipto ([custid],[firstname],[lastname],[company],[addr1],[addr2],[city],[state],[zip],[phone]) values(&quot;
sql = sql &custid &&quot;,&quot;
sql = sql & &quot;'&quot;&sfirstname&&quot;',&quot;
sql = sql & &quot;'&quot;&slastname&&quot;',&quot;
sql = sql & &quot;'&quot;&scompany&&quot;',&quot;
sql = sql & &quot;'&quot;&saddr1&&quot;',&quot;
sql = sql & &quot;'&quot;&saddr2&&quot;',&quot;
sql = sql & &quot;'&quot;&scity&&quot;',&quot;
sql = sql & &quot;'&quot;&sstate&&quot;',&quot;
sql = sql & &quot;'&quot;&szip&&quot;',&quot;
sql = sql & &quot;'&quot;&sphone&&quot;');&quot;

'response.write &quot;<br>&quot;&sql&&quot;<br>&quot;

oConn.execute(sql)
'now get shiptoid
sql = &quot;select max([id]) as shiptoid from cart_shipto ;&quot;
rs.open sql,oConn
do while not rs.eof
shiptoid = rs(&quot;shiptoid&quot;)
rs.movenext
loop
rs.close()
end if

' now we set up the insert into cart_final checkout
sql = &quot;INSERT INTO Cart_FinalCheckout ([custid],[custshiptoid],[cctype],[ccnum],[ccexp],[totalretail],[totalshipping],[totaltax],[totalorder]) values( &quot;
sql = sql & custid &&quot;,&quot;
sql = sql & shiptoid &&quot;,&quot;
sql = sql & &quot;'&quot;&cctype&&quot;',&quot;
sql = sql & &quot;'&quot;&ccnum&&quot;',&quot;
sql = sql & &quot;'&quot;&ccmonth&&quot;/&quot;&ccyear&&quot;',&quot;
sql = sql & TotalRetail &&quot;,&quot;
sql = sql & TotalShipping &&quot;,&quot;
sql = sql & TotalTax &&quot;,&quot;
sql = sql & TotalOrder &&quot;)&quot;

'response.write &quot;<br>&quot;&sql&&quot;<br>&quot;

oConn.Execute(sql)
DIM OrderNumber
OrderNumber=0
sql = &quot;select max([ordernum]) as ordernumber from cart_finalcheckout ;&quot;
'response.write &quot;<br>&quot;&sql&&quot;<br>&quot;
rs.open sql,oConn
do while not rs.eof
OrderNumber = rs(&quot;ordernumber&quot;)
rs.movenext
loop
rs.close()

sql = &quot;update cart_items set [ordernumber] = &quot;&OrderNumber&&quot; where [custid]=&quot;&custid&&quot; and [ordernumber]=0 ;&quot;
'response.write &quot;<br>&quot;&sql&&quot;<br>&quot;
oConn.Execute(sql)



%>
<html>
<head>
<title>LuggageMan Confirmation Page</title>
</head>
<body bgcolor=&quot;#FFFFFF&quot;>
<center>

<!-- Header Section -->
<!--#include file=&quot;header.asp&quot;-->
<!-- End Header Section -->

<!-- Start Body Section -->
<p>
<table width=&quot;640&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;>
<tr><td bgcolor=&quot;#FF0000&quot;><center><font size=&quot;+1&quot; face=&quot;Arial&quot; color=&quot;#FFFFFF&quot;>

Order Confirmation

</font></center></td><td align=&quot;right&quot;><IMG SRC=&quot;images/noclose.gif&quot; ALIGN=RIGHT WIDTH=&quot;80&quot; HEIGHT=&quot;10&quot; BORDER=&quot;0&quot; HSPACE=&quot;0&quot; VSPACE=&quot;0&quot;></td></tr>
</table>
<p>
<table width=&quot;640&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;>
<tr><td valign=&quot;top&quot;>
<font size=&quot;-1&quot; face=&quot;Arial&quot;>
<b>Order Confirmation</b>
<p>
Thank you for placing your order (<b>Order# <%=OrderNumber%></b>). Your order will be processed and shipped as quickly as possible.
<p>
<table width=&quot;640&quot; border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot;>
<tr>
<td colspan=&quot;2&quot;><%= bfirstname %> <%= blastname %><br>
<%= bcompany %><br>
<%= baddr1 %><br>
<%= baddr2 %><br>
<%= bcity %>, <%= bstate %> <%= bzip %><br>
<%= bphone %><br>
<%= bemail %><br></td>
</tr>
<tr>
<td colspan=&quot;2&quot;>
<table width=&quot;640&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;>
<tr>
<td height=&quot;23&quot;><b>Sku</b></td>
<td height=&quot;23&quot;><b>Color</b></td>
<td height=&quot;23&quot;><b>Desc</b></td>
<td height=&quot;23&quot; align=&quot;center&quot;><b>Qty</b></td>
<td height=&quot;23&quot; align=&quot;right&quot;><b>Retail</b></td>
<td height=&quot;23&quot; align=&quot;right&quot;><b>Shipping</b></td>
<td height=&quot;23&quot; align=&quot;right&quot;><b>Total</b></td>
<td height=&quot;23&quot;> </td>
</tr>
<%

sql = &quot;select cart_items.*,products.* from cart_items INNER JOIN Products ON (Cart_Items.colorcode = Products.ColorCode) AND (Cart_Items.SKu = Products.SKU) where cart_items.[custID] = &quot;& custid &&quot; and cart_items.[ordernumber] = &quot;&OrderNumber
'response.write &quot;<BR>&quot;&sql&&quot;<BR>&quot;
rs.open sql,oConn
DIM productName
do while not rs.eof

productName = trim(rs(&quot;productName&quot;))

if(left(productName,1) = &quot;&quot;&quot;&quot;) then
productName = mid(productName,2)
end if
if(right(productName,1) = &quot;&quot;&quot;&quot;) then
productName = mid(productName,1,(len(productName)-1))
end if
if(instr(productName,&quot;&quot;&quot;&quot;&quot;&quot;) > 0) then
productName = Replace(productName,&quot;&quot;&quot;&quot;&quot;&quot;,&quot;&quot;&quot;&quot;)
end if


%>
<tr>
<td><%= rs(&quot;brandID&quot;) %> <%=rs(&quot;fullsku&quot;)%></td>
<td><%=trim(rs(&quot;colordesc&quot;))%></td>
<td><%=productName%></td>
<td align=&quot;center&quot;><%=rs(&quot;qty&quot;)%></td>
<td align=&quot;right&quot;><%=formatcurrency(rs(&quot;Retail&quot;))%></td>
<td align=&quot;right&quot;><%=formatcurrency(rs(&quot;cart_items.shipping&quot;))%></td>
<td align=&quot;right&quot;><%=formatcurrency( ( rs(&quot;Retail&quot;)*rs(&quot;qty&quot;) ) + ( rs(&quot;cart_items.shipping&quot;)*rs(&quot;qty&quot;) ) ) %></td>
<td> </td>
</tr>
<%
rs.movenext
loop

rs.movefirst
rs.Close()


%>
<tr>
<td colspan=&quot;5&quot;> </td>
<td align=&quot;right&quot;>Total Retail</td>
<td align=&quot;right&quot;><%=FormatCurrency(TotalRetail)%></td>
<td> </td>
</tr>
<tr>
<td colspan=&quot;5&quot;> </td>
<td align=&quot;right&quot;>Total Shipping</td>
<td align=&quot;right&quot;><%=FormatCurrency(TotalShipping)%></td>
<td> </td>
</tr>
<tr>
<td colspan=&quot;5&quot;> </td>
<td align=&quot;right&quot;>Total Tax</td>
<td align=&quot;right&quot;><%=FormatCurrency(TotalTax)%></td>
<td> </td>
</tr>
<tr>
<td colspan=&quot;5&quot;> </td>
<td align=&quot;right&quot;>Total Order</td>
<td align=&quot;right&quot;><b><%=FormatCurrency(TotalOrder)%></b></td>
<td> </td>
</tr>
</table>

<p>
If you have any questions, please <a href=&quot;contactus.asp&quot;>contact us</a>.
<p>

</font>
<p>
<center>
<script language=&quot;Javascript1.2&quot;>
<!--
// please keep these lines on when you copy the source

var message = &quot;Click to Print this Page for your Records&quot;;

function printpage() {
window.print();
}

document.write(&quot;<form><input type=button &quot;
+&quot;value=\&quot;&quot;+message+&quot;\&quot; onClick=\&quot;printpage()\&quot;></form>&quot;);

//-->
</script>
</center></td></tr>

<!-- Footer Starts-->
<!--#include file=&quot;footer.asp&quot;-->
<!-- Footer Ends-->
</table>

<%
oConn.close
set oConn = Nothing
set rs = Nothing
' send the email
dim from:from = &quot;sales@luggagebase.com&quot;
dim sendTo:sendTo = bemail
dim subject:subject = &quot;Luggagebase.com - OrderNumber #&quot; & OrderNumber

dim strMessage

strMessage = &quot; &quot;& bfirstname &&quot;,&quot;& vbCrLf &_
&quot;Thank you for your order! Placed on &quot;& date &&quot;.&quot;& vbCrLf & vbCrLf &_
&quot;Your Order Number is &quot;& cstr(OrderNumber) &&quot;. &quot;&_
&quot;This number may be used to track the progress of your order &quot;&_
&quot;by contacting our customer service department.&quot; & vbCrLf & vbCrLf &_
&quot;Your Name and Address&quot; & vbCrLf &_
bfirstname & &quot; &quot; & blastname & vbCrLf

If Len(bcompany) > 0 Then strMessage = strMessage & bcompany & vbCrLf

strMessage = strMessage & baddr1 & vbCrLf

If Len(baddr2) > 0 Then strMessage = strMessage & baddr2 & vbCrLf

strMessage = strMessage & bcity & &quot;, &quot; & bstate & &quot; &quot; & bzip & vbCrLf
strMessage = strMessage & vbCrLf

If (bfirstname & blastname) <> (sfirstname & slastname) and (sfirstname <> &quot;&quot;) Then
strMessage = strMessage & vbCrLf & &quot;Ship-To Name and Address&quot; & vbCrLf &_
sfirstname & &quot; &quot; & slastname & vbCrLf

If Len(scompany) > 0 Then strMessage = strMessage & scompany & vbCrLf

strMessage = strMessage & saddr1 & vbCrLf

If Len(saddr2) > 0 Then strMessage = strMessage & saddr2 & vbCrLf

strMessage = strMessage & scity & &quot;, &quot; & sstate & &quot; &quot; & szip & vbCrLf

strMessage = strMessage & vbCrLf

End If

strMessage = strMessage & vbCrLf & &quot;Your order includes the following items:&quot; & vbCrLf
' 1 2 3 4 5 6 7 8 9 10
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
strMessage = strMessage & &quot;Item Number / Description Price Qty &quot; & vbCrLf
'123456789012345678901234567890 99,999.99 12345 678 99,999.99

DIM oConn2,rs2
set oConn2= Server.CreateObject(&quot;ADODB.connection&quot;)
set rs2=Server.CreateObject(&quot;ADODB.recordset&quot;)
oConn2.ConnectionString = strConnectionString
oConn2.Open
rs2.open sql,oConn2,3,3

rs2.movefirst
do while not rs2.eof

productName = trim(rs2(&quot;productName&quot;))

if(left(productName,1) = &quot;&quot;&quot;&quot;) then
productName = mid(productName,2)
end if
if(right(productName,1) = &quot;&quot;&quot;&quot;) then
productName = mid(productName,1,(len(productName)-1))
end if
if(instr(productName,&quot;&quot;&quot;&quot;&quot;&quot;) > 0) then
productName = Replace(productName,&quot;&quot;&quot;&quot;&quot;&quot;,&quot;&quot;&quot;&quot;)
end if

strMessage = strMessage &_
left( rs2(&quot;fullsku&quot;) & &quot; / &quot; & productName & space(30),30) & space(2) &_
right( space(10) & formatcurrency(rs2(&quot;Retail&quot;)),10) &_
right( space(10) & rs2(&quot;qty&quot;),10) &_
space(1) & trim(rs2(&quot;colordesc&quot;)) & vbCrLf &_
&quot; &quot; & vbCr & vbCr

rs2.movenext
loop

rs2.Close()

strMessage = strMessage & &quot;SubTotal: &quot; & right(space(10) & formatcurrency(TotalRetail) ,10) & vbCrLf &_
&quot;Sales Tax: &quot; & right(space(10) & formatcurrency(TotalTax) ,10) & vbCrLf &_
&quot;Shipping: &quot; & right(space(10) & formatcurrency(TotalShipping) ,10) & vbCrLf &_
&quot;Order Total: &quot; & right(space(10) & formatcurrency(TotalOrder),10) & vbCrLf & vbCrLf &_
&quot;FOR YOUR INFORMATION : &quot;& vbCrLf & vbCrLf &_
&quot;* Returns and Exchanges : Go to then visit our Customer Service department and choose from the appropriate menu. &quot;& vbCrLf & vbCrLf &_
&quot;Customer Service e-mail address : service@luggagebase.com&quot;& vbCr & vbCr &_
&quot;* Customer Service Hours : &quot;& vbCrLf &_
&quot; 8:30-5:00 PST (Pacific Time)&quot;& vbCrLf &_
&quot;* Off-line Order Desk : &quot;& vbCrLf &_
&quot; United States residents: 1-888-832-1201&quot;& vbCrLf &_
&quot;* All orders may be subject to Voice Authorization&quot; & vbCrLf & vbCrLf &_
&quot;* luggagebase.com retains the right to refuse service to anyone&quot; & vbCrLf & vbCrLf &_
&quot;* The &quot;&quot;List&quot;&quot;, and/or &quot;&quot;SRP&quot;&quot; prices associated with many products throughout luggagebase.com are the manufacturer's &quot;&_
&quot;suggested retail prices which are intended to be used for reference only and do not necessarily represent the present &quot;&_
&quot;or former selling price of luggagebase.com or any specific retailer.&quot; & vbCrLf & vbCrLf


call SendMail(sendTo, From, Subject, strMessage)

%>

</center>
</body>
</html>
 
sql = &quot;update cart_items set [ordernumber] = &quot;&OrderNumber&&quot; where [custid]=&quot;&custid&&quot; and [ordernumber]=0 ;&quot;

is this the one you're inserting your cart items into the database? It's not in a loop or anything???
 
This statement updates the cart with the next available order #. I looked at the database and the order numbers are all being updated without a loop statement. Here is something that might help also, the part that writes out the html receipt prints out everything fine, but only the email is the part that gets cut off after the first cart item.

Thanks in advance!
 
Place a print statement inside the loop that creates the email body, perhaps a counter that incrememnts with each loop or somesuch, so that you can see that it is actually going through the whole process.
Also, I noticed with the second OPen statement you are using the flags 3,3 while with the first (working) open you are not using flags, could this be making the differance?
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top