Hi,
I have some code to run for emailing multiple members. It works beautifully but it is based on a table. I want it to draw the data from a query rather than a table. Can I do that by calling the query or do I have to enter the sql statement? Any help would be greatly appreciated. Here is my code.
Private Sub Email_Click()
On Error Resume Next
Dim db As DAO.database
Dim rs As DAO.Recordset
Dim txtTO, txtSubject, txtMessage As String
Dim clsSendObject As accSendObject
Dim strMsg As String
Set clsSendObject = New accSendObject
txtTO = ""
txtSubject = "Place the subject of the email here"
txtMessage = "Place the message for the email here"
Set db = CurrentDb
Set rs = db.OpenRecordSet("MultipleVouchers", dbOpenDynaset)
rs.MoveFirst
Do
If Not IsNull(rs("Email") Then
txtTO = txtTO & rs("Email" & ";"
End If
rs.MoveNext
Loop Until rs.EOF
txtTO = Mid$(txtTO, 1, Len(txtTO) - 1)
clsSendObject.SendObject acSendReport, "MultipleVouchers", accOutputSNP, _
txtTO, , , txtSubject, txtMessage, True
rs.Close
db.Close
Set clsSendObject = Nothing
End Sub
I have some code to run for emailing multiple members. It works beautifully but it is based on a table. I want it to draw the data from a query rather than a table. Can I do that by calling the query or do I have to enter the sql statement? Any help would be greatly appreciated. Here is my code.
Private Sub Email_Click()
On Error Resume Next
Dim db As DAO.database
Dim rs As DAO.Recordset
Dim txtTO, txtSubject, txtMessage As String
Dim clsSendObject As accSendObject
Dim strMsg As String
Set clsSendObject = New accSendObject
txtTO = ""
txtSubject = "Place the subject of the email here"
txtMessage = "Place the message for the email here"
Set db = CurrentDb
Set rs = db.OpenRecordSet("MultipleVouchers", dbOpenDynaset)
rs.MoveFirst
Do
If Not IsNull(rs("Email") Then
txtTO = txtTO & rs("Email" & ";"
End If
rs.MoveNext
Loop Until rs.EOF
txtTO = Mid$(txtTO, 1, Len(txtTO) - 1)
clsSendObject.SendObject acSendReport, "MultipleVouchers", accOutputSNP, _
txtTO, , , txtSubject, txtMessage, True
rs.Close
db.Close
Set clsSendObject = Nothing
End Sub