I get the 2501 error stating that the Out put to was canceled without anyone cancelling it. I go to debug and it points to lines 21 and 22.
I do not have any issues running this on my PC, but I have a user that gets this every time he try's to run this code.
I gave his PC full control of the folder the database is in thinking it was a rights issue but that did not help either.
I do not have any issues running this on my PC, but I have a user that gets this every time he try's to run this code.
I gave his PC full control of the folder the database is in thinking it was a rights issue but that did not help either.
Code:
Option Explicit Option Compare Database Private Sub btnMail1_Click() Dim strEMail As String Dim oOutlook As Object Dim oMail As Object Dim strAddr As String Dim MyDB As DAO.Database Dim rstEMail As DAO.Recordset Dim strReportName As String Set oOutlook = CreateObject("Outlook.Application") Set oMail = oOutlook.CreateItem(0) strReportName = "New ECN Report" gstrFilter = "[ECNID]=" & Me.ECNID DoCmd.OutputTo acOutputReport, "rptECN", acFormatPDF, CurrentProject.Path & _ "\" & strReportName & ".pdf", , , , acExportQualityPrint 'Retrieve all E-Mail Addressess in tblEMailAddress Set MyDB = CurrentDb Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail", dbOpenSnapshot, dbOpenForwardOnly) With rstEMail Do While Not .EOF 'Build the Recipients String strEMail = strEMail & ![EmailAddress] & ";" .MoveNext Loop End With '-------------------------------------------------- With oMail .To = Left$(strEMail, Len(strEMail) - 1) 'Remove Trailing ; .Body = "Please review the attached ECN and complete any and all tasks that pertain to you." .Subject = Replace(Replace("ECNID |1: |2", "|1", Nz([ECNID], "")), "|2", Nz([NewPN], "")) .Display .Attachments.Add CurrentProject.Path & "\" & strReportName & ".pdf" End With Set oMail = Nothing Set oOutlook = Nothing rstEMail.Close Set rstEMail = Nothing Dim aFile As String aFile = "M:\Unsecure Share\New ECN System\New ECN Report.pdf" If Len(Dir$(aFile)) > 0 Then Kill aFile End If End Sub