I'm needing some help with a small piece of code. I'm tring to send out an email through Lotus Notes, using a query that defines the emails to send on my bcc line. I've got everything working except for the loop. The loop current will go through and send the correct number of emails for the total amount of records (ie five records five emails are sent, three records three emails sent, etc), however the same email address (the first record) is getting the email each time (instead of rolling to next record and pulling it's email address). Any help is appreciated.
Private Sub Send_Click()
Dim Email As String
Dim ref As String
Dim notes As String
Dim nosession As Object
Dim noDatabase As Object
Dim noDocument As Object
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim db As DAO.Database
Set db = CurrentDb
Set qdf = db.QueryDefs("Test")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset
Email = rs!EmailAddress
ref = Me.Subject
notes = Me.Memo
Set nosession = CreateObject("Notes.NotesSession")
Set noDatabase = nosession.GETDATABASE("", "")
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
Set noDocument = noDatabase.CreateDocument
rs.MoveFirst
Do Until rs.EOF
With noDocument
.Form = "Memo"
.BlindCopyTo = Email
.Subject = ref
.Body = notes
.SaveMessageOnSend = True
.PostedDate = Now()
.Send 0
End With
rs.MoveNext
Loop
MsgBox "Your email has been sent", vbInformation
Set nosession = Nothing
Set noDatabase = Nothing
Set noDocument = Nothing
End Sub
Private Sub Send_Click()
Dim Email As String
Dim ref As String
Dim notes As String
Dim nosession As Object
Dim noDatabase As Object
Dim noDocument As Object
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim db As DAO.Database
Set db = CurrentDb
Set qdf = db.QueryDefs("Test")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset
Email = rs!EmailAddress
ref = Me.Subject
notes = Me.Memo
Set nosession = CreateObject("Notes.NotesSession")
Set noDatabase = nosession.GETDATABASE("", "")
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
Set noDocument = noDatabase.CreateDocument
rs.MoveFirst
Do Until rs.EOF
With noDocument
.Form = "Memo"
.BlindCopyTo = Email
.Subject = ref
.Body = notes
.SaveMessageOnSend = True
.PostedDate = Now()
.Send 0
End With
rs.MoveNext
Loop
MsgBox "Your email has been sent", vbInformation
Set nosession = Nothing
Set noDatabase = Nothing
Set noDocument = Nothing
End Sub