Dim strBody As String
Me.clientemail = DLookup("[email]", "tblclients", "[clientid] = Parent![clientid]")
Me.usercompany = DLookup("[companyname]", "tblusersettings")
'Email Client'
strBody = "Dear valued customer," & vbCrLf & vbCrLf & _
"Below you will find your invoice, credit memo, sales receipt, or statement. If you need to remit payment, please do so at your earliest convenience." & vbCrLf & vbCrLf & _
"Thank you for your business- we appreciate it very much." & vbCrLf & vbCrLf & _
"Total Due:" & Me.Text194 & vbCrLf & _
"Sincerely," & vbCrLf & _
Me.usercompany
DoCmd.OpenReport "invoiceLH", acPreview, , "[invoiceid]=" & Me![invoiceid], acHidden
DoCmd.SendObject acSendReport, "invoiceLH", acFormatPDF, _
"" & Me.clientemail, _
, _
, _
"Notification from " & Me.usercompany, _
"" & strBody, _
True
Exit Sub
Error_Handle:
DoCmd.Close acReport, invoiceLH, acSaveNo
If Err.Number = 2501 Then
MsgBox "The email was canceled and has not been sent", , "Email Invoice"
Else
DoCmd.Close acReport, invoiceLH, acSaveNo
MsgBox Err.Number & Err.description
Exit Sub
Exit_Error_Handle:
Exit Sub
End If
|