CBragg
VB Dummy
- Local time
- Today, 15:52
- Joined
- Oct 21, 2002
- Messages
- 89
Right, so far i have some code which should loop through every record on my for and send an email until it gets to the end of the file. For some reason it wont move to the next record using rsEmail.MoveNext, if i change this to the docmd.gotorecord,, acnext record then it creates a new one at the end of the records. Can anyone help?? Here's my code:
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Dim intEmail as Integer
Dim i as Integer
Set rsEmail = CurrentDb.OpenRecordset("SELECT * FROM tbl WHERE SEND = True")
'Refresh recordset
'There may be a more efficient way of doing this, but I usually use
rsEmail.MoveLast
rsEmail.MoveFirst
'Count the records in the recordset
intEmail = rsEmail.RecordCount
'Set the email subject, body, and add the first recipient email
EmailSend.Subject = "Information Systems - Hardware Audit"
EmailSend.HTMLBody = "TESTING"
EmailSend.Recipients.Add rsEmail!Email
'Loop through all records and add the email addresses, one at a time, to the email item
For i = 1 to intEmail
rsEmail.MoveNext
EmailSend.Recipients.Add Email
Next
'Send the email
EmailSend.Send
Set rsEmail = Nothing
MsgBox "Your Message has been sent successfully!"
End Sub
Any ideas would be greatly appreciated.
Cheers.
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Dim intEmail as Integer
Dim i as Integer
Set rsEmail = CurrentDb.OpenRecordset("SELECT * FROM tbl WHERE SEND = True")
'Refresh recordset
'There may be a more efficient way of doing this, but I usually use
rsEmail.MoveLast
rsEmail.MoveFirst
'Count the records in the recordset
intEmail = rsEmail.RecordCount
'Set the email subject, body, and add the first recipient email
EmailSend.Subject = "Information Systems - Hardware Audit"
EmailSend.HTMLBody = "TESTING"
EmailSend.Recipients.Add rsEmail!Email
'Loop through all records and add the email addresses, one at a time, to the email item
For i = 1 to intEmail
rsEmail.MoveNext
EmailSend.Recipients.Add Email
Next
'Send the email
EmailSend.Send
Set rsEmail = Nothing
MsgBox "Your Message has been sent successfully!"
End Sub
Any ideas would be greatly appreciated.
Cheers.