mike60smart
Registered User.
- Local time
- Today, 19:09
- Joined
- Aug 6, 2017
- Messages
- 2,020
Hi Everyone
I am trying to attach a PDF file as an attachment to an EMail but when I run the Code I get the following Error.
The Report opens just fine but no EMail is generated.
Any help appreciated.
I am trying to attach a PDF file as an attachment to an EMail but when I run the Code I get the following Error.
The Report opens just fine but no EMail is generated.
Any help appreciated.
Code:
Private Sub cmdPreview_Click()
10 If Me.Dirty Then Me.Dirty = False
20 On Error GoTo cmdPreview_Click_Error
30 If Me.Dirty Then Me.Dirty = False ' force a save
Dim strPDFFilenameToStore As String
40 strPDFFilenameToStore = "C:\Quotes\" & Format(Date, "yyyymmdd") & " - QuoteNo Nr - '" & [OrderNo] & "'.pdf"
Dim strDocName As String
Dim strWhere As String
Dim strSubject As String
Dim strBody As String
Dim strJN As String
50 strJN = Me.OrderNo
60 strDocName = "rptCustomerQuote"
70 strWhere = "[OrderNo]='" & Me!OrderNo & "'"
80 strSubject = "Quote Attached"
90 strBody = "Find attached the Quote for your Project"
100 DoCmd.OutputTo acOutputReport, strDocName, acFormatPDF, strPDFFilenameToStore
110 DoCmd.OpenReport "rptCustomerQuote", acViewPreview, , "[OrderNo]='" & Me!OrderNo & "'"
120 Debug.Print strPDFFilenameToStore
130 DoCmd.SendObject _
ObjectType:=acSendReport, _
ObjectName:="rptCustomerQuote", _
OutputFormat:=acFormatPDF, _
To:=Me.Email, _
Subject:=strSubject, _
MessageText:=strBody, _
EditMessage:=True
140 On Error GoTo 0
150 Exit Sub
cmdPreview_Click_Error:
160 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdPreview_Click, line " & Erl & "."
End Sub