Question Sending Multiple .pdf Reports Using Sendobject Acsendreport (1 Viewer)

oxicottin

Learning by pecking away....
Local time
Today, 02:26
Joined
Jun 26, 2007
Messages
856
Hello, I already have a button to attach a renamed Report/.pdf to an email but now I'm needing to attach a second renamed Report/.pdf. How can I do this using the existing code below?

Code:
Dim sExistingReportName As String
    Dim sAttachmentName As String
    Dim strSViser As String
    
    strSViser = frm.cboSupervisorName.Column(1)
    
    'Input variables
    sExistingReportName = "rpt_EmailDailyProduction"    'Name of the Access report Object to send
    sAttachmentName = Format(Date, "MM-dd-yyyy") & " " & strSViser & " Superlog"    'Name to be used for the attachment in the e-mail

    
    DoCmd.OpenReport sExistingReportName, acViewPreview, , , acHidden 'Opens report hidden
    Reports(sExistingReportName).Caption = sAttachmentName    'by changing the report caption
                                                        
    DoCmd.SendObject acSendReport, sExistingReportName, acFormatPDF, sTOEmailList, , , "Daily Production", stText
    DoCmd.Close acReport, sExistingReportName 'Closes the open report
 

vba_php

Forum Troll
Local time
Today, 01:26
Joined
Oct 6, 2019
Messages
2,880
I don't know for sure, but I can offer something here...

have you looked up the SendReport() action on MS's MSDN knowledgebase? it should tell you there what all it can do and what it can't do. I would assume you can only send one object at a time using this function, as the name itself implies that. I would further assume that if you want to send multiple report objects attached to the same email, you would have to do it with a vba outlook.application object.
 

oxicottin

Learning by pecking away....
Local time
Today, 02:26
Joined
Jun 26, 2007
Messages
856
If you cant do send object then how could you save and rename the reports then attach them?
 

vba_php

Forum Troll
Local time
Today, 01:26
Joined
Oct 6, 2019
Messages
2,880
If you cant do send object then how could you save and rename the reports then attach them?
I think there is a FAQ thread here on this forum that shows you how to write VBA code that uses outlook.application as an object instance, and if you can get a hold of that, you can google the rest. if you can't fine it, you can always google strings like "ms access vba send [outlook] email". then from that you can find the ".attachment" attribute of the email object that you need to add multiple attachments. it might be the ".attachments.add" method, I'm not sure but that sounds familiar.

you can also email a report as a snapshot object. I wrote the attached file quite some time ago. I hope it still works. if you have a minute, see if it's useful to you.
 

Attachments

  • E-mail-Report-Snapshot-to-Multiple-Recipients.zip
    28.4 KB · Views: 119

Users who are viewing this thread

Top Bottom