Good morning,
I have a form button containing the following code to send an email to multiple recipients. It currently reads from a table (tblEmailList) with one field (EMail). The code reads all email addresses using a recordset
Dim stSubject As String
Dim strEmailAddress
Dim strEmailMessage
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblEmailList")
Do Until rst.EOF
strEmailAddress = strEmailAddress & rst("EMail") & ","
rst.MoveNext
Loop
stSubject = "Test Subject:- "
strEmailMessage = "Test:"
strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)
DoCmd.SendObject , , , strEmailAddress, , , stSubject, strEmailMessage
*This code works fine as it is. However based on whoever is sending the email, that is, an admin sends an email to all supervisors or a supervisor sends the email to a user. Rather then referring to different email tables, I want to try and use the one table.
In the tblEmailList, I have added an additional field called Type. There are two different types in this data field - User and Super
Is there any way I can add to the code above so that it only pulls in email addresses that have Type "Super"??
Many thanks
Larry B
I have a form button containing the following code to send an email to multiple recipients. It currently reads from a table (tblEmailList) with one field (EMail). The code reads all email addresses using a recordset
Dim stSubject As String
Dim strEmailAddress
Dim strEmailMessage
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblEmailList")
Do Until rst.EOF
strEmailAddress = strEmailAddress & rst("EMail") & ","
rst.MoveNext
Loop
stSubject = "Test Subject:- "
strEmailMessage = "Test:"
strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)
DoCmd.SendObject , , , strEmailAddress, , , stSubject, strEmailMessage
*This code works fine as it is. However based on whoever is sending the email, that is, an admin sends an email to all supervisors or a supervisor sends the email to a user. Rather then referring to different email tables, I want to try and use the one table.
In the tblEmailList, I have added an additional field called Type. There are two different types in this data field - User and Super
Is there any way I can add to the code above so that it only pulls in email addresses that have Type "Super"??
Many thanks
Larry B