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

'Loop' recordset and send by email 2

Status
Not open for further replies.

perryair

IS-IT--Management
Apr 7, 2005
91
0
0
IL
Hi All,
Below are the objMail that I need to send by email using ASPmail, when I send this form I receive only 1 record from the SQL database and it seems the 'rsProd.MoveNext' and 'wend' doesn't work properly.
Can you point me to the right direction how to 'Loop' this recordset.


set rsProdInfo = Server.CreateObject("ADODB.Recordset")
rsProdInfo_Open "balls", Conn, adOpenStatic, adLockOptimistic, adCmdTable

intTotal = 0

rsProd.MoveFirst
do while not rsProd.EOF
rsProdInfo.MoveFirst
rsProdInfo.Find "productID = " & rsProd("productID")
intProdID = rsProdInfo("catalogID")
intProdIDshow = rsProdInfo("productID")
intImgNumber = rsProdInfo("ImgNumber")
intMKT = rsProdInfo("MKT")
strProdName = rsProdInfo("itemname")
intPrice = formatNumber(rsProdInfo("productPrice"), 2)
intQuant = rsProd("quantity")
intExtPrice = formatNumber((intPrice * intQuant), 2)
intTotal = intTotal + intExtPrice

sBody = "<html dir=ltr>" & _
"<head>" & _
"</head>" & _
"<body >" & _
"<tr>" & _
"<td width=15" & "%" & " valign=center align=center style=border: 1px solid #E1E2CB; nowrap><font face=arial size=2>" & intQuant & "</font></td>" & _
"<td width=15" & "%" & " valign=center align=center style=border: 1px solid #E1E2CB; nowrap><font face=arial size=2><a href=index.asp?intCatalogID=" & intProdID & "&" & "pid=" & intImgNumber & ">" & intMKT& "</a></font></td>" & _
"<td width=37" & "%" & " valign=center align=center style=border: 1px solid #E1E2CB; nowrap><font face=arial size=2><a href=index.asp?intCatalogID=" & intProdID & "&" & "pid=" & intImgNumber & ">" & strProdName & "</a></font></td>" & _
"<td width=17" & "%" & " valign=center align=center style=border: 1px solid #E1E2CB; nowrap><font face=arial size=2>" & intPrice & "</font><font face=arial size=2> $</font></td>" & _
"<td width=15" & "%" & " valign=center align=center style=border: 1px solid #E1E2CB; nowrap><font face=arial size=2>" & intExtPrice & "</font><font face=arial size=2> $</font></td>" & _
"</tr>" & _
"<input type=hidden name=strOrderItem value=" & intProdIDshow & "," & intQuant & ">" & _
"</body>" & _
"</html>"

rsProd.MoveNext
wend

Dim objMail
strEmail = Request.Form("strEmail")
sSubject = "test"

Set objMail = Server.CreateObject("SMTPsvg.Mailer")
objMail.RemoteHost = "mail.mydomain.com" ' Specify a valid SMTP server
objMail.FromAddress = "admin@mydomain.com"
objMail.FromName = "My Name"
objMail.Recipient = strEmail
objMail.Subject = sSubject
objMail.BodyText = sBody

objMail.ContentType = "text/html"
objMail.Priority = 0
objMail.SendMail
Set objMail = Nothing
 
umm..I think this may have soemthing to do with it ;)

Code:
             rsProd.MoveFirst
             do while not rsProd.EOF
                 rsProdInfo.MoveFirst


 
Where?
I have it in my code, can you explain please?

Thanks.
 
Looks like you have a 'Do...Wend' Loop!

Use EITHER :
Do While Not rs.EOF
...
...
Loop

OR:
While Not rs.EOF
...
...
Wend

Do...While is probably more commonly used nowadays


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top