I’m getting a Run-time error ‘2501’” The SendObject action was cancelled. Message when I cancel sending an email generated with the following code (cancel occurs within Outlook). When I select Debug the DoCmd.SendObject line is highlighted:
Code: Select all
Private Sub lblNewEmail_Click() Dim sExistingReportName As String Dim sAttachmentName As String 'Input variables sExistingReportName = "RptIndividualDonarRcpt2" sAttachmentName = "Gram Seva Foundation Donation Receipt" DoCmd.OpenReport sExistingReportName, acViewPreview, , , acHidden Reports(sExistingReportName).Caption = sAttachmentName DoCmd.SendObject acSendReport, sExistingReportName, "PDFFormat(*.pdf)", [E Mail], , , "Gram Seva Foundation Donation Receipt For " & [First Name] & " " & [Last Name] & "", "Receipt for your donation attached. Thank you for your generous support." & vbCrLf & "Gram Seva Foundation", True, "" DoCmd.Close acReport, sExistingReportName DoCmd.Close acForm, "frmqryDonationDepDatePopup" cmdlblNewEmail_Click_Exit: Exit Sub cmdlblNewEmail_Click_Err: MsgBox "You have cancelled the Email Receipt Action. Click OK to get back to work.", vbInformation, "Gram Seva Foundation" Resume cmdlblNewEmail_Click_Exit End Sub
Any help would be appreciated.
Happy New Year to all!