473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How do you send multiple reports with the docmd.sendobject?

anoble1
245 128KB
Hi,
I have a database that sends out emails to users that contains a few reports. I am trying to come up with a way that will combine the reports in 1 email. Is that possible?

Here is my code.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acOutputReport, "rptPSSREmail" & "rptPSSRMonthlyLaborSalesbyPSSR", acFormatPDF, "myemail.com"
I get an error with the code above because I am trying to combine 2 reports. How do I do this? I am trying to attach 3 reports to one email.

Thanks,
Feb 15 '16 #1
5 4109
ADezii
8,834 Expert 8TB
Is Microsoft Outlook your E-Mail Client?
Feb 16 '16 #2
anoble1
245 128KB
Yes, it is MS Outlook
Feb 16 '16 #3
ADezii
8,834 Expert 8TB
  1. Save/Export each Report as a *.pdf.
  2. Open Microsoft Outlook using Automation Code.
  3. Attach each Exported Report (*.pdfs) to the E-Mail which results in an E-Mail being sent to a single Recipient, with multiple Attachments.
Feb 16 '16 #4
anoble1
245 128KB
The code I have attaches one attachment in Outlook when it opens, but not the 3 attachments. I am not sure how to feed 3 reports into 1 email.
Feb 16 '16 #5
ADezii
8,834 Expert 8TB
The following Code will:
  1. Create a New Instance of Microsoft Outlook.
  2. Loop thru every Report in the Database and if it begins with rptPSSR, namely (rptPSSR*) Export that Report in *.pdf Format to the same Folder that the Database is in, Attach that Report to an E-Mail with previously defined Parameters, then finally Delete the *.pdf.
  3. Once all Reports in the form of *.pdfs have been attached, opens the Outlook Window with the appropriate To:, From:, Subject:, and Body: Fields populated along with Multiple Attachments.
  4. The Code has been tested and is fully operational'
    Expand|Select|Wrap|Line Numbers
    1. 'First, set a Reference to the Microsoft Outlook XX.X Object Library
    2. Dim aob As AccessObject
    3. Dim oLook As New Outlook.Application
    4. Dim oMail As Outlook.MailItem
    5. Dim olns As Outlook.Namespace
    6.  
    7. Set olns = oLook.GetNamespace("MAPI")
    8.  
    9. Set oMail = oLook.CreateItem(0)
    10.  
    11. With oMail
    12.   .To = "MyEMail.com"
    13.   .Body = "Attached, please find a Summary Report for your review."
    14.   .Subject = "My Subject"
    15. End With
    16.  
    17. For Each aob In CurrentProject.AllReports
    18.   If Left$(aob.Name, 7) = "rptPSSR" Then
    19.     DoCmd.OutputTo acOutputReport, aob.Name, acFormatPDF, CurrentProject.Path & _
    20.                    "\" & aob.Name & ".pdf", False
    21.       oMail.attachments.Add CurrentProject.Path & "\" & aob.Name & ".pdf"
    22.         Kill CurrentProject.Path & "\" & aob.Name & ".pdf"
    23.   End If
    24. Next
    25.  
    26. oMail.Display
Feb 16 '16 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alfred | last post by:
Hi I am using access 2002 1.0 I want to email a word or html file using the docmd.sendobject The document must be send as a attachment. 2.0 Second I would like to tell the Docmd.Sendobject to...
5
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting...
7
by: Mega1 | last post by:
is this possable to send more than 1 report in one email
1
by: jerry.ranch | last post by:
I collect information from my clients with an xls file I import the xls data into my access table. I don't have them put info directly into Access, because, despite the drop downs I have for...
1
RobH
by: RobH | last post by:
i currently send a report to a reciepient using the Docmd.Sendobject acSendReport which works really well - now my customer wants two reports sent in the same email.. Any thoughts???
5
by: neosam | last post by:
Hey all, I am not able to integrate these 2 actions in one command. What i am doing is... A button which sends a report with only specific data to a particular person (via outlook). I am able to...
2
iBasho
by: iBasho | last post by:
Hi, I am trying to set up a notification email that would come to my email everytime users click on a command button in a form. I am using the DoCmd.SendObject command without actually sending any...
5
by: MyWaterloo | last post by:
I am currently using... DoCmd.SendObject acReport, BactPDF, acFormatPDF, Me.Text199, , , "BacT Results " & Me.Report_Heading ...to email my report. I have now come up against a need to send...
2
by: austinboston | last post by:
I've gone down the road of using docmd.sendobject for sending out reports from an access database because I don't have to save the attachment to media that way, I can just create and send. My problem...
1
anoble1
by: anoble1 | last post by:
I am trying to email 3 reports with 1 function where it will email 3 attachments. Right now, i can only send 1 attachment at a time. My question is; how do I send multiple reports along with this:...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.