Hello all, been a regular visitor but never got around to signing up.
Ok, heres my issue, have written code to mail out, no probs, but to get around ips limitations I have decided to send them in batches. The loop is giving ne a headache, I know its obvious but am missing it, keep getting an eof error. The loop shows 164 email in database, groups them in lots of 20 but gives me an eof error with the remaining 4 records. Be damned if I get see what I have missed.
Test code as follows:
Public Function Test(myRS As String)
'?Test("qry_newsletter_email")
Dim DB As DAO.Database
Dim MailList As DAO.Recordset
Dim MyBCC As String
Dim myCount, totalEmails, myBatch As Integer
Dim myRemainder As Integer
Set DB = CurrentDb()
Set MailList = DB.OpenRecordset(myRS)
myBatch = 20
MyBCC = ""
myCount = 1
MailList.MoveLast
totalEmails = MailList.RecordCount
myRemainder = totalEmails Mod myBatch
Debug.Print "ttl:" & (totalEmails - myRemainder)
Debug.Print "rem:" & myRemainder
MailList.MoveFirst
Do Until MailList.EOF
For myCount = 1 To myBatch
MyBCC = MyBCC & MailList("Email") & "(" & myCount & ");"
MailList.MoveNext
Next
Debug.Print MyBCC
MyBCC = ""
Loop
MailList.Close
Set MailList = Nothing
DB.Close
Set DB = Nothing
End Function
Ok, heres my issue, have written code to mail out, no probs, but to get around ips limitations I have decided to send them in batches. The loop is giving ne a headache, I know its obvious but am missing it, keep getting an eof error. The loop shows 164 email in database, groups them in lots of 20 but gives me an eof error with the remaining 4 records. Be damned if I get see what I have missed.
Test code as follows:
Public Function Test(myRS As String)
'?Test("qry_newsletter_email")
Dim DB As DAO.Database
Dim MailList As DAO.Recordset
Dim MyBCC As String
Dim myCount, totalEmails, myBatch As Integer
Dim myRemainder As Integer
Set DB = CurrentDb()
Set MailList = DB.OpenRecordset(myRS)
myBatch = 20
MyBCC = ""
myCount = 1
MailList.MoveLast
totalEmails = MailList.RecordCount
myRemainder = totalEmails Mod myBatch
Debug.Print "ttl:" & (totalEmails - myRemainder)
Debug.Print "rem:" & myRemainder
MailList.MoveFirst
Do Until MailList.EOF
For myCount = 1 To myBatch
MyBCC = MyBCC & MailList("Email") & "(" & myCount & ");"
MailList.MoveNext
Next
Debug.Print MyBCC
MyBCC = ""
Loop
MailList.Close
Set MailList = Nothing
DB.Close
Set DB = Nothing
End Function