C
clk
I have a button that generates all invoices where the client prefers
to be emailed their invoice. I now need to set up code to email each
invoice to a specific customer. For example, I may generate 10
invoices for the day all marked to be emailed. I want to click a
button that will create and email all 10 invoices to their respective
contacts stored in the tblcustomer.
Here is the code I have so far which generates one invoice. Not sure
how it is going to work when there is multiple invoices created. Each
invoice needing to be sent to a separate person.
Private Sub Command17_Click()
On Error Resume Next
If MsgBox("This will send invoices to customers marked to email.
Continue?", _
vbExclamation + vbYesNoCancel) = vbYes Then
Dim strMailList As String
Dim rs As Recordset
sqlStmt = "select * From qryEmailCustomers where [CustomerID]='" &
[CustomerID] & "'"
'Set rs = CurrentDb.OpenRecordset("qryEmailCustomers", dbOpenDynaset)
Set rs = CurrentDb.OpenRecordset(sqlStmt, dbOpenDynaset)
With rs
.MoveFirst
Do
strMailList = strMailList & !EMail & ";"
strMailList = strMaiList & !EMail
.MoveNext
Loop Until .EOF
strMailList = Left(strMailList, Len(strMailList) - 1)
.Close
End With
DoCmd.SendObject acSendReport, "rptInvoicesEmail", acFormatSNP,
strMailList, , , "INVOICE" _
, , True
End If
Set rs = Nothing
End Sub
This code was gathered on the forums and I am not sure who originally
wrote it.
Any help would be greatly appreciated.
~ Carrie
to be emailed their invoice. I now need to set up code to email each
invoice to a specific customer. For example, I may generate 10
invoices for the day all marked to be emailed. I want to click a
button that will create and email all 10 invoices to their respective
contacts stored in the tblcustomer.
Here is the code I have so far which generates one invoice. Not sure
how it is going to work when there is multiple invoices created. Each
invoice needing to be sent to a separate person.
Private Sub Command17_Click()
On Error Resume Next
If MsgBox("This will send invoices to customers marked to email.
Continue?", _
vbExclamation + vbYesNoCancel) = vbYes Then
Dim strMailList As String
Dim rs As Recordset
sqlStmt = "select * From qryEmailCustomers where [CustomerID]='" &
[CustomerID] & "'"
'Set rs = CurrentDb.OpenRecordset("qryEmailCustomers", dbOpenDynaset)
Set rs = CurrentDb.OpenRecordset(sqlStmt, dbOpenDynaset)
With rs
.MoveFirst
Do
strMailList = strMailList & !EMail & ";"
strMailList = strMaiList & !EMail
.MoveNext
Loop Until .EOF
strMailList = Left(strMailList, Len(strMailList) - 1)
.Close
End With
DoCmd.SendObject acSendReport, "rptInvoicesEmail", acFormatSNP,
strMailList, , , "INVOICE" _
, , True
End If
Set rs = Nothing
End Sub
This code was gathered on the forums and I am not sure who originally
wrote it.
Any help would be greatly appreciated.
~ Carrie