Hi All
I have been trying to workout how to add the customer name and date to an pdf when it's e-mailed
i have this code on the e-mail invoice button
Private Sub E_Mail_Invoice_Click()
'This Command Opens the report in hidden mode so that the calculations work on the Report when it's output as a PDF
DoCmd.OpenReport "Invoice", acViewPreview, "", "", acHidden
DoCmd.OutputTo acOutputReport, "Invoice", acFormatPDF, DLookup("FilePath", "Company Details", "CompanyID = 1") & "\Invoice.pdf" '"Filepath from company form"
Dim OlApp As Object
Dim objMail As Object
On Error Resume Next 'Keep going if there is an error
Set OlApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set OlApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook
End If
'Create e-mail item
Set objMail = OlApp.CreateItem(olMailItem)
'Set objOutlookAttach = .Attachments.Add DLookup("FilePath", "Company Details", "CompanyID = 1") & "\Invoice.pdf"
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = Me.EMail.Value
.Subject = "Invoice Attached"
.HTMLBody = "Dear" & " " & Me.Full_Name.Value & " " & Me.Email_Body_text.Value
.Attachments.Add DLookup("FilePath", "Company Details", "CompanyID = 1") & "\Invoice.pdf" '("filepath= folder in which to save pdfs toas found on the company setting form")
.Display
End With
Set OlApp = Nothing
Set objMail = Nothing
DoCmd.Close acReport, "Invoice", acSaveYes
Me.Order_Sent_Date = Date
End Sub
what i am trying to do is change the name of the PDF attached from "invoice.pdf" to "fullname - order date - invoice.pdf"
i have tried putting
.Attachments.Add DLookup("FilePath", "Company Details", "CompanyID = 1") & "Me.Full_Name" & "me.Date_of_Order" &"\Invoice.pdf"
when this is used the attachment is not added to the e-mail
any help would be wonderful
Many thanks
Steve