View Single Post
  #1 (permalink)  
Old January 30th, 2004, 10:35 AM
jimmlegs jimmlegs is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mail Loop Will Randomly Stop Working

I have a vbScript that is being kicked off in a MS SQL 7 DTS package that will inform new members when they have signed up, it done in batches and not real time. The setup is such:
*The script is supposed to scan a binary field and send emails with a membership ID to the appropriate email address when the field is true
*If any of the fields are false, exit the script and notify administrator
*Every record is set to true
*I am using the SMTP engine on IIS 5 on a Win2k Server box

The issue:
*The script sometimes works, but it apparently will randomly stop looping and only notify the first record in the table

The script:
Option Explicit

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Dim objConnection, objRecordset

    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordset = CreateObject("ADODB.Recordset")
    objConnection.Open "DSN=email;"
    objRecordset.CursorLocation = adUseClient
    objRecordset.Open "SELECT * FROM email", objConnection, _
    adOpenStatic, adLockOptimistic


Dim recip, mem_id, objEmail, flag, message, subject, dsg


    objRecordset.MoveFirst
        While Not objRecordset.EOF
        flag=objRecordset("flag")

                If flag = false Then
                  recip="[email protected]"
                        message="This script did not detect any flagged fields. Please cross check the database to ensure accuracy"
                  subject="Script Error"
                ' objRecordset.GetString
                ' Wscript.Echo recip
                ' Wscript.Echo subject
                      ' Wscript.Echo message

                      Set objEmail = CreateObject("CDO.Message")
                            objEmail.From = "[email protected]"
                            objEmail.To = recip
                            objEmail.Subject = subject
                            objEmail.Textbody = message
                            objEmail.Send
                             set objEmail = Nothing
                   Wscript.Quit
        End If

         objRecordset.MoveNext

        Wend

    objRecordset.MoveFirst
        While Not objRecordset.EOF
        flag=objRecordset("flag")

             If flag = true Then
                            recip=objRecordset ("email")
                mem_id=objRecordset("mem_id")
                subject="INTA Membership Account Activation"
               'Wscript.Echo recip
               'Wscript.Echo subject
                     'Wscript.Echo mem_id

            Set objEmail = CreateObject("CDO.Message")
                      objEmail.From = "[email protected]"
                      objEmail.To = recip
                      objEmail.Subject = subject
                      objEmail.Textbody = mem_id
                      objEmail.Send
            set objEmail = Nothing
            objRecordset.MoveNext

                    End If


    Wend

objRecordset.Close
objConnection.Close
set objRecordset = Nothing
set objConnection = Nothing

David S. Goldstein
"Alpha Male" At Large
Reply With Quote