Hi,
I am trying to convert a report to a PDF and attach this straight into an email and send it. I have managed to convert the report to the PDF and attach the file to the email but not with the correct name. I need the PDF to be named using the value stored in a text box on the input form named 'reference'. Once saved with this reference it would then need to be attached with this value. Added the code used so far.
Dim oApp As Outlook.Application
Dim oMail As MailItem
Dim strReportName As String
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem)
strReportName = Forms!InputForm!reference
DoCmd.OpenReport "PrintForm3", acViewReport
DoCmd.OutputTo acOutputReport, strReportName, _
acFormatPDF, "C:\Users\UI741406\Desktop\strReportName.pdf"
oMail.Body = "Hi, A new evaluation has been completed for the above Reference. Input this reference into the database to provide feedback
oMail.Subject = "Reference - " & "" & Me.reference & " " & "Advisor -" & " " & Me.agent
oMail.To = Me.emailaddress
oMail.Attachments.Add "C:\Users\UI741406\Desktop\&strReportName.pdf"
oMail.Display
Thanks
I am trying to convert a report to a PDF and attach this straight into an email and send it. I have managed to convert the report to the PDF and attach the file to the email but not with the correct name. I need the PDF to be named using the value stored in a text box on the input form named 'reference'. Once saved with this reference it would then need to be attached with this value. Added the code used so far.
Dim oApp As Outlook.Application
Dim oMail As MailItem
Dim strReportName As String
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem)
strReportName = Forms!InputForm!reference
DoCmd.OpenReport "PrintForm3", acViewReport
DoCmd.OutputTo acOutputReport, strReportName, _
acFormatPDF, "C:\Users\UI741406\Desktop\strReportName.pdf"
oMail.Body = "Hi, A new evaluation has been completed for the above Reference. Input this reference into the database to provide feedback
oMail.Subject = "Reference - " & "" & Me.reference & " " & "Advisor -" & " " & Me.agent
oMail.To = Me.emailaddress
oMail.Attachments.Add "C:\Users\UI741406\Desktop\&strReportName.pdf"
oMail.Display
Thanks