Hi Guy's can the following code be changed to generate an email to all recipients, in the field i will have either a valid email address or Enter Email Address, the myExclude string does bypass anything that is Enter Email Address and goes to a record that has got a valid email address and opens x 1 email, I am looking to adapt it so a separate email is generated for each valid email address
Code:
Dim strEMail As StringDim oOutlook As Object
Dim oMail As Object
Dim strAddr As String, myExclude As String
Dim MyDB As DAO.Database
Dim rstEMail As DAO.Recordset
Set oOutlook = CreateObject("Outlook.Application")
Set oMail = oOutlook.CreateItem(0)
myExclude = "Enter Email Address"
Set MyDB = CurrentDb
Set rstEMail = MyDB.OpenRecordset("Select * From tblCustomers WHERE InvoiceEmail <> '" & myExclude & "'", dbOpenSnapshot, dbOpenForwardOnly)
With rstEMail
Do While Not .EOF
strEMail = rstEMail.Fields("InvoiceEmail") & ";"
.MoveNext
Loop
End With
With oMail
.To = strEMail
.Body = "Test E-Mail to Multiple Recipients"
.Subject = "Test multiple emails"
.Display
End With
Set oMail = Nothing
Set oOutlook = Nothing
rstEMail.Close
Set rstEMail = Nothing