I am learning some code and am generally interested. I am building a database. For this purpose I have the following.
Router2: Table that has "Family", "Department", "Name"
EMails: Table that has "Name" , "EMail"
Eng_types: Table that has "engine_type", and "Family"
Routerchain: Quary that combines all of this and creates an email list. This is where I am trying to send the email from.
I have this so far. When I put in the quary a filter [Engine_Type:], this doesn't work. I also want the subject line to include "Please review the following new part" and "Engine Part". If I take out the quary filter, it works, but I get an email with all of the emails. I want it filtered.
Public Function CreateRIT_ReportEmail()
'write the default Outlook contact name list to the active worksheet
Dim rs As DAO.Recordset
Dim OlApp As Object
Dim OlMail As Object
Dim ToRecipient As String
Set OlApp = CreateObject("Outlook.Application")
Set OlMail = OlApp.createitem(olmailitem)
Set rs = CurrentDb.OpenRecordset("SELECT Email FROM routerchain")
Do While rs.EOF = False
ToRecipient = rs!email
OlMail.Recipients.Add ToRecipient
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
'fill in Subject field
OlMail.Subject = "New Quote"
'Display the message
OlMail.Display 'change this to OlMail.Send if you just want to send it without previewing it
End Function