Print Page | Close Window

1 email - 2 loops

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6433
Printed Date: 31 March 2026 at 3:07pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: 1 email - 2 loops
Posted By: zaboss
Subject: 1 email - 2 loops
Date Posted: 15 October 2003 at 8:31am

I have a testing apps which has 2 loops: 1 is gathering the questions, 1 is gathering the answers, something like that:

<%
Set RSQ= MyConn.Execute("Select * from Interviuri_Intrebari where ID_Interviu = '"& Request.QueryString("int") &"'")
If not RSQ.Eof then
RSQ.MoveFirst
do
Response.Write RSQ("Question") & "<br>"
Set RSR = MyConn.Execute("Select * from Interviuri_Raspunsuri where ID_Intrebare = '"&RSQ("ID_Intrebare") &"' AND UserName = '"& Session("UserName") &"'")
If not RSR.Eof then
RSR.MoveFirst
do
Response.Write RSR("Raspuns") & "<br>"
RSR.MoveNext
Loop Until RSR.EOF
End IF
RSQ.MoveNext
Loop until RSQ.Eof
End if

Well, I need to send all the above test by email. How could I do that? I have tryed to make some strings out of them but to no avail...



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Replies:
Posted By: vshriniwasan
Date Posted: 16 October 2003 at 8:37am

You are doing too many things going on here... Just simply do two small loops..

Set RSQ= MyConn.Execute("Select * from Interviuri_Intrebari where ID_Interviu = '"& Request.QueryString("int") &"'")

Do until RSQ.eof

Set RSR = MyConn.Execute("Select * from Interviuri_Raspunsuri where ID_Intrebare = '"&RSQ("ID_Intrebare") &"' AND UserName = '"& Session("UserName") &"'")

Do until RSR.eof

your Stuff....

RSR.movenext
loop

RSQ.movenext
loop



Posted By: zaboss
Date Posted: 16 October 2003 at 11:30am
Is not the problem. Is mailing the results.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: vshriniwasan
Date Posted: 16 October 2003 at 1:59pm

Can you add the mailing code so we can see. That way we can just see what is going on in the mailing code. What are you using... CDONTS or SMTP



Posted By: zaboss
Date Posted: 17 October 2003 at 12:58am

<%
Set RSQ= MyConn.Execute("Select * from Interviuri_Intrebari where ID_Interviu = '"& Request.QueryString("int") &"'")
If not RSQ.Eof then
RSQ.MoveFirst
do
Response.Write RSQ("Question") & "<br>"
Set RSR = MyConn.Execute("Select * from Interviuri_Raspunsuri where ID_Intrebare = '"&RSQ("ID_Intrebare") &"' AND UserName = '"& Session("UserName") &"'")
If not RSR.Eof then
RSR.MoveFirst
do
Response.Write RSR("Raspuns") & "<br>"
RSR.MoveNext
Loop Until RSR.EOF
End IF
RSQ.MoveNext
Loop until RSQ.Eof
End if
' Send Mail Copy to Admin

 Dim objMail
 Dim strBody
       strBody = "<h2>Rezultatele testului pentru candidatul " & Session("UserName") & "</h2><br>"
    strBody = strBody & "La testul nr. " & Request.QueryString("int") &" candidatul " & Session("UserName") & " a raspuns in felul urmator:<br> "
    strBody = strBody & Here it should be the loops' results
  strBody = strBody & "Pentru a vizualiza reultatele candidatilor, trebuie sa va logati in contul dumneavoastra de pe site.<br>"
    strBody = strBody & "<a href = http://www.testarionline.ro>TestariOnline.ro - http://www.testarionline.ro>TestariOnline.ro</a >"
   
  Set objMail = Server.CreateObject("CDONTS.NewMail")

  objMail.From = " mailto:webmaster@mydomains.ro - webmaster@mydomains.ro "
  objMail.Subject = "Rezultatul testului"
  Set rsTo = MyConn.Execute ("Select Email from Login where ID_Firma = "& Session("ID_Firma") & " AND Tip_Cont = ""Companie""")
  objMail.To = rsTo("email")
  objMail.Bcc = " mailto:myemail@mydomains.ro - myemail@mydomains.ro "
  objMail.BodyFormat =0
  objMail.MailFormat = 0
  objMail.Body = strBody

  objMail.Send
  On Error resume Next

  'You must always do this with CDONTS.
  set objMail = nothing
  ' End of Mail Function
  RSTo.close
  set RSTo = nothing
'___________________________________________________________ ____ 
RSQ.Close
RSR.Close
Set RSR = Nothing
Set RSQ = nothing
MyConn.Close
Set MyConn = Nothing


Response.Redirect("menuc.asp")
%>



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net