Hi can any help me with this compilation error? I downloaded it to send an email with an attached report from Access 365 because the Docmd. SendObject was not working. I was getting 2293 error. Thank you very much for you help. I am a newbie.
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Dim fileName As String, todayDate As String
'Export report in same folder as db with date stamp
todayDate = Format(Date, "MMDDYYYY")
fileName = Application.CurrentProject.Path & "\rptCarlsbad_" & todayDate & ".pdf"
DoCmd.OutputTo acReport, "rptCarlsbad", acFormatPDF, fileName, False
'Email the results of the report generated
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.Recipients.Add "myemailaddress@email.com"
.Subject = "Water Testing Report"
.Body = "Attached is your Water Testing Report"
.Attachments.Add fileName
.Send
End With
MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"
End Sub
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Dim fileName As String, todayDate As String
'Export report in same folder as db with date stamp
todayDate = Format(Date, "MMDDYYYY")
fileName = Application.CurrentProject.Path & "\rptCarlsbad_" & todayDate & ".pdf"
DoCmd.OutputTo acReport, "rptCarlsbad", acFormatPDF, fileName, False
'Email the results of the report generated
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.Recipients.Add "myemailaddress@email.com"
.Subject = "Water Testing Report"
.Body = "Attached is your Water Testing Report"
.Attachments.Add fileName
.Send
End With
MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"
End Sub