title: Asp classic 3.0 loop and movenext
body: <p>I have problem with this Asp Classic 3.0 code.</p>
  
  <p>I need send email message when the sql query found in database table the records with :</p>
  
  <pre><code>SQL = " SELECT * FROM doTable Where div = 1; "
  </code></pre>
  
  <p>And I have tried this Asp code:</p>
  
  <pre><code>   SQL = " SELECT * FROM doTable Where div = 1; "
  
     Set Rec = createObject("ADODB.Recordset")
     Rec.open SQL, cn
  
     If not Rec.eof then
  
     msg = msg &amp; VBcrlf &amp; "&lt;br /&gt;Records founds!&lt;br /&gt;"
  
     Do while not Rec.eof 
  
     msg = msg &amp; VBcrlf &amp; "ID record: " &amp; Rec("Id") &amp; ""         
  
     msg = ""
  
     Rec.moveNext()      
     Loop       
  
     Else
  
     msg = msg &amp; VBcrlf &amp; "&lt;br /&gt;No records!&lt;br /&gt;"
  
     End If
  
     Rec.close()
     set Rec = nothing    
  
     cn.close()
     set cn = nothing 
  </code></pre>
  
  <p>The problem is this part of code:</p>
  
  <pre><code>msg = ""
  </code></pre>
  
  <p>If I have found records and the <strong>msg = ""</strong> is present in code the output of msg is empty; if the <strong>msg = ""</strong> is not present in code the output is:</p>
  
  <pre><code>Records founds!
  ID record: 32
  Records founds!
  ID record: 61
  Records founds!
  ID record: 77
  </code></pre>
  
  <p>Why can not I get this output ?</p>
  
  <pre><code>Records founds!
  ID record: 32
  ID record: 61
  ID record: 77
  </code></pre>
  
  <p>Can you help me?
  Thank you in advance-</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>With objMessage 
      .From     = RS("Email_from")
      .To       = RS("Email_to")
      .Subject  = "Alert div"
      .HtmlBody = msg
      .Fields("urn:schemas:httpmail:importance").Value = 2 
      .Fields("urn:schemas:mailheader:X-MSMail-Priority") = 6
      .Fields.Update()    
  
  on error resume next
     .Send
      if Err.Number &lt;&gt; 0 then
         response.Write "Email send failed # : " &amp; Err.Number &amp; " -  " &amp; Err.Description &amp; ".&lt;br /&gt;"&amp;vbcrlf
      end if  
  
  End With
  </code></pre>