This is for monthly invoice statements.
I have a parameter in the query to pull the exact attachments I need by date.
My query records start with a unique(Autonumber) id, and includes the e-mail address and the path to the attachment, The attachment is on the same drive/network.
This is an example of a query record
STID CustID ACCT APCEmail STMTAP STDATE STMTPATH
30 740 999999 hmb@123.com TRUE 1/5/2019 C:\Users\Summaries\EMAIL\999999.xlsx
My first problem is on Set rsEmail, runtime 3061 with two few parameters. Is this VBA correct to open a parameter query?
Expand|Select|Wrap|Line Numbers
- Dim MyDb As DAO.Database
- Dim rsEmail As DAO.Recordset
- Dim sToName As String
- Dim sSubject As String
- Dim sMessageBody As String
- Set MyDb = CurrentDb()
- Set rsEmail = MyDb.OpenRecordset("qrysendEMstmt", dbOpenSnapshot)
- With rsEmail
- .MoveFirst
- Do Until rsEmail.EOF
- If IsNull(.Fields(3)) = False Then
- sToName = .Fields(3)
- sSubject = "SG Acct Summary: " & .Fields(2)
- sMessageBody = ""Please find attached account summary for your reconciliation." & vbNewLine & "Kindly feedback payment status." & vbNewLine & "Thank you!"
- DoCmd.SendObject acSendObject, , , _
- sToName, , , sSubject, sMessageBody, False, False
- End If
- .MoveNext
- Loop
- End With
- Set MyDb = Nothing
- Set rsEmail = Nothing