You need a tELog table to track who/when when you sent the emails.
At the SEND1EMAIL you would run a query to add the email address to the log file
Code:
Public Sub SendRstEmails()
Dim rst As DAO.Recordset
Dim strBody
Dim vTo, vSubj
Set fso = CreateObject("Scripting.FileSystemObject")
Set rst = currentdb.openrecordset("qsEmails")
'================
'send 1 email with everyones address, or
'================
vSubj = "Teste" & " " & rst![SAP] & " " & rst![Nome]
While Not rst.EOF
vTo = vTo & rst![Email] & ";"
rst.MoveNext
Wend
Send1Email vTo, vSubj, strBody
rst.Close
Set rst = Nothing
End Sub
'================
'sent many emails, 1 per person
'================
While Not rst.EOF
vTo = rst![Email]
vSubj = "Teste" & " " & rst![SAP] & " " & rst![Nome]
Send1Email vTo, vSubj, strBody
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
End Sub
'-------
'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!! checkmark OUTLOOK OBJECTS in the vbE menu, Tools, References
'-------
Public Function Send1Email (ByVal pvTo, ByVal pvSubj, ByVal pvBody, optional pvFile ) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.To = pvTo
.Subject = pvSubj
.Body = pvBody
.Attachments.Add pvFile, olByValue, 1
.Send
End With
EmailO = True
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume Next
End Function