By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

Sending an Access Report as an attachment via Outlook automatically

P: 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
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,638
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

P: 11
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
Expert 5K+
P: 8,638
As stated by the OP:
The SendObject method is not an option.
Jan 25 '12 #4

P: 1
@ADezii
Hello, how would you modify this to send more than one report and also add more email recipients?
Mar 5 '14 #5

Post your reply

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