I managed to get everything working except the send Email from query part. I found a code, altered it and that works just fine. However, with this code an email will be sent to everyone in the table “tblAdressen”.
I need the code changed so that only the people shown in the query receive an email.
My table where all the information is is called tblAdressen
The query with the people who should receive an e-mail is called abfKundeninteresseArtikelMail and is open
Can you help me?
Dim rs As DAO.Recordset
Dim OlApp As Object
Dim OutMail As Object
Dim strEmail As String
Dim bccEmails As String
Set OlApp = CreateObject("Outlook.Application")
Set OutMail = OlApp.CreateItem(olMailItem)
Set rs = CurrentDb.OpenRecordset("SELECT Mailadresse FROM tblAdressen")
With rs
Do Until .EOF
strEmail = !Mailadresse
' add email to BCC email list string
bccEmails = bccEmails & strEmail & ";"
rs.MoveNext
Loop
End With
rs.Close
Set rs = Nothing
' set BCC using string of concatenated emails
OutMail.BCC = Left(bccEmails, Len(bccEmails) - 1) ' trims trailing semicolon
OutMail.Display
Talibasch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1