472,357 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Sending an Access Report as an attachment via Outlook automatically

1
I'm trying to send an existing Access Report as an attachment via MS Outlook. The SendObject method is not an option.

Since, the report i'm trying to send is an access object it is not stored at a particular path on the PC/network.

Any help would be greatly appreciated! This is what I have tried so far but have been running out of options...
Expand|Select|Wrap|Line Numbers
  1. Dim objOutlook As New Outlook.Application
  2. Dim ObjOutlookMsg As Outlook.MailItem
  3.  
  4. Set ObjOutlookMsg = objOutlook.CreateItem(olMailItem)
  5. With ObjOutlookMsg
  6. .To = aRecipients
  7. .Subject = "test"
  8. .Body = "hi"
  9. .Body = "Body of email"
  10. .Attachments = aAttachments ( I believe this is where I need help)
  11. .Send
  12. End With
  13. Set ObjOutlookMsg = Nothing
  14. Set objOutlook = Nothing
Jan 23 '12 #1
4 12613
ADezii
8,832 Expert 8TB
Here is Code that Saves a Report as an *.rtf File, Attaches the Report to an E-Mail addressed to JDoe@aol.com, then Sends the E-Mail via Outlook:
Expand|Select|Wrap|Line Numbers
  1. 'Set a Reference to the Microsoft Outlook ?X.X Object Library
  2. Dim strReportName As String
  3. Dim oLook As Object
  4. Dim oMail As Object
  5. Dim olns As Outlook.NameSpace
  6. Dim strTO As String
  7. Dim strMessageBody As String
  8. Dim strSubject As String
  9.  
  10. strReportName = "rptEmployees"
  11. DoCmd.OutputTo acOutputReport, strReportName, acFormatRTF, CurrentProject.Path & _
  12.                "\" & strReportName & ".rtf", False
  13.  
  14. Set oLook = CreateObject("Outlook.Application")
  15. Set olns = oLook.GetNamespace("MAPI")
  16. Set oMail = oLook.CreateItem(0)
  17.  
  18. '*********************** USER DEFINED SECTION ************************
  19. strTO = "JDoe@aol.com"
  20. strMessageBody = "Here is the Report that you requested"
  21. strSubject = "Test Project for Attaching Access"
  22. '*********************************************************************
  23.  
  24. With oMail
  25.  .To = strTO
  26.  .Body = strMessageBody
  27.  .Subject = strSubject
  28.  .Attachments.Add CurrentProject.Path & "\" & strReportName & ".rtf"
  29.    '.Display
  30.      .Send
  31. End With
  32.  
  33. Set oMail = Nothing
  34. Set oLook = Nothing
Jan 24 '12 #2
it is quite simple really

Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acSendReport, "MyReport", acFormatRTF, "theemail@emails.com", , , "Here is your report"
note if you are using a later version of access you can use acFormatPDF to present your report in PDF format
Jan 25 '12 #3
ADezii
8,832 Expert 8TB
As stated by the OP:
The SendObject method is not an option.
Jan 25 '12 #4
@ADezii
Hello, how would you modify this to send more than one report and also add more email recipients?
Mar 5 '14 #5

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

Similar topics

7
by: Susan Bricker | last post by:
I would like to generate a report (I have the report working already) using MS/ACCESS 2000 and then have the ability to send the report as an email attachment to my colleagues. I have looked...
15
by: Mark C | last post by:
All, I have exhaustingly been looking through the newsgroups in search of a way to systemically output an Access 97 report to a pdf file using the full version of Adobe Acrobat. I want the user...
1
by: Aby Mathews | last post by:
I am using Cutepdf to convert access report to pdf format. It's working fine. How can I set the save location and save as file by default and how can I attach this file automatically to outlook....
0
by: Bob Alston | last post by:
I am having trouble on a client PC getting the Office link, to send an access report I am viewing to MS Word. Also I cannot get send to - mail recipient to work either. The command box pops up...
1
by: Dirk Goossens | last post by:
Hello! I'm sending E-mails to mailadresses in a table, using the code below. How can I send more than one attachment? Access can find the file to be send in this field: MY_EMAILATTACHMENT_FIELD...
5
by: handokowidjaja | last post by:
Hi All, I'm trying to automate sending an email with an attachment in our environment (access 97) using Outlook Express ( we dont have MS outlook or other fancy stuff). Does anybody knows how to...
4
akabir77
by: akabir77 | last post by:
Hi I am using the following code to convert a access report into HTML format and then sending it via email. DoCmd.SendObject _ acSendReport, _ ...
2
by: neosam | last post by:
Hi, Could someone tell me if the code i have written has the correct syntax. DoCmd.SendObject acSendReport as acSpreadSheetType , "reportname", , "email@id.com", , , "report", "Pls find...
1
by: shalskedar | last post by:
My Query is Can we create an exe file specifically for Ms Access Report because In my Database(Acess 2003)I need to send 1 of the Report as an attachment via Ms Outlook. If I try to send this...
5
MDestructive
by: MDestructive | last post by:
First, let me say that VBA is not my strong point but I have been bestowed with creating a duplicate database of a former employee who sabotaged the original. And everyday this isn't working is...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.