jsterling0231
New member
- Local time
- Today, 18:01
- Joined
- May 29, 2013
- Messages
- 5
Hi All,
I am trying to email a group of records in a table and with the code I have written, it just loops to the first record in the recordset and will not move down to the next record. Can someone please help me with this problem. Below is my code.
Thanks for all your help :banghead:
I am trying to email a group of records in a table and with the code I have written, it just loops to the first record in the recordset and will not move down to the next record. Can someone please help me with this problem. Below is my code.
Code:
Private Sub TestOutlook()
Dim db As Database
Dim rstMail As Recordset
Dim appOutlook As Outlook.Application
Dim MailOutlook As Outlook.MailItem
Set db = CurrentDb
Set rstMail = db.OpenRecordset("tblEmail", dbOpenDynaset)
Do Until rstMail.EOF
Set appOutlook = CreateObject("outlook.application")
Set MailOutlook = appOutlook.CreateItem(olMailItem)
With MailOutlook
.BodyFormat = olFormatRichText
.To = DLookup("Email", "tblEmail")
.Subject = DLookup("Subject", "tblEmail")
.Send
End With
Set MailOutlook = Nothing
Set appOutlook = Nothing
rstMail.MoveNext
Loop
End Sub
Thanks for all your help :banghead: