I am trying to use the sendobject function to send emails. I am able to send the beginning record through email, but when I tell it to move to the next record, I still get the beginning record. Here is some code that I am working on. I tried writing a SQL statement to reference the "TO" field, but it didn't work correctly.
Code:
Dim xls As Object
Dim objrs As Recordset
Dim xlapp As Excel.Application
Dim xlbook As Excel.worksheet
Dim xlSheet As Excel.worksheet
Dim mysheetpath As String
Dim sql As String
DoCmd.SetWarnings False
sql = "SELECT DISTINCT qryOfficerEmail.[BI71_ADMIN_OFFICER_EMAIL]"
sql = sql + " from qryOfficerEmail"
'Execute query and export to C:\
'DoCmd.OpenQuery "Query1"
'DoCmd.OpenQuery "qryOfficerEmail"
'DoCmd.OutputTo acOutputTable, "tbltest", acFormatXLS, "C:\testfile.xls", False
Set rst = CurrentDb.OpenRecordset("tblOfficersEmail")
Do Until rst.EOF
'Will have to insert a loop here to go through the entire table
'DoCmd.SendObject acSendQuery, "qryOfficerEmail", acFormatXLS, [BI71_ADMIN_OFFICER_EMAIL], , , "Test Email", " if you have any questions, please contact TSS.", False
DoCmd.SendObject acSendTable, "tblOfficersEmail", acFormatXLS, BI71_ADMIN_OFFICER_EMAIL, , , "TEST", "TESTING", False
rst.MoveNext
Loop
DoCmd.SetWarnings True
'DoCmd.Quit
End Sub