Graham T
Registered User.
- Local time
- Today, 12:05
- Joined
- Mar 14, 2001
- Messages
- 300
I am trying to send separate e-mails for each record in a query, one e-mail per row of the query. The following code is what is being used and this is what is causing the problems. The code writes the results of various fields into the body of the e-mail (strEMailMsg) as text and not as an attachment.
The first problem is that if I open the database and use the SendMail command it will send one e-mail, but will not send again until I close down the database and reopen, then it will.
The second problem is that it will only send one e-mail containing the first record in the recordset (qrySendMail), which at present contains 5 test records to send.
Can anybody see or does anybody know if this is possible.
I have also attached the database, Access 2000 version to see if anyone may shed any light on this. I have trawled previous posts but can find any solution to this.
TIA
Graham
The first problem is that if I open the database and use the SendMail command it will send one e-mail, but will not send again until I close down the database and reopen, then it will.
The second problem is that it will only send one e-mail containing the first record in the recordset (qrySendMail), which at present contains 5 test records to send.
Can anybody see or does anybody know if this is possible.
Code:
Private Sub cmdSendMail_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSubject As String
Dim strEmailAddress As String
Dim strEMailMsg As String
strSubject = "Job Outcomes"
strEmailAddress = "graham"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qrySendMail")
rst.MoveFirst
Do Until rst.EOF
strEMailMsg = rst![strStudentName] & " " & "aged" & " " & rst![strAge] _
& " has informed us of his new job entitled " & rst![strNewJob] & "." & Chr(10) & Chr(10) _
& "He has given us these details: " & rst![strJobDetails] & Chr(10) & Chr(10) _
& "Angela"
DoCmd.SendObject , , acFormatRTF, strEmailAddress, , , strSubject, strEMailMsg, False, False
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
End Sub
TIA
Graham