Results 1 to 2 of 2
  1. #1
    Pimped is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    25

    Unhappy Send Report and Attachments in Email

    Hey guys



    Scenario: User is looking at a job details. Job has pictures and PDF's as external files saved in the filesystem of the computer. User clicks Email Invoice. System attaches report as a PDF and opens Outlook Email message with email address, subject and body filled and the report PDF as an attachment

    I can currently send a report as an attachment in an Outlook Email by using the "DoCmd.SendObject acSendReport" code.

    That works nicely for me because it attaches the report I specify but has the limitation that I cannot attach any other objects.

    I therefore came across the following code which allows me to add multiple attachments to an Outlook email message:

    Code:
    Sub CreateEmail()
    
    'write the default Outlook contact name list to the active worksheet
    
    Dim OlApp As Object
    Dim OlMail As Object
    Dim ToRecipient As Variant
    Dim CcRecipient As Variant
    
    Set OlApp = CreateObject("Outlook.Application")
    Set OlMail = OlApp.createitem(olmailitem)
    
    For Each ToRecipient In Array("User 1", "User 2", "User 3")
    OlMail.Recipients.Add ToRecipient
    Next ToRecipient
    
    For Each CcRecipient In Array("User 4", "User 5", "User 6")
    With OlMail.Recipients.Add(CcRecipient)
    .Type = olCC
    End With
    Next CcRecipient
    
    'fill in Subject field
    OlMail.Subject = "Test of Outlook email"
    
    'Add the active workbook as an attachment
    OlMail.Attachments.Add "C:\Users\User\Pictures\Unspecified\01.jpg"
    OlMail.Attachments.Add "C:\Users\User\Pictures\Unspecified\02.jpg"
    
    'Display the message
    OlMail.Display 'change this to OlMail.Send if you just want to send it without previewing it
    
    End Sub
    The problem with the above is that I cannot figure out how to attach a report of my choice. I don't know if there is a way to tell access to open a report and attach it as a PDF (in the above code).

    Worst comes to worst, I'll try to figure out a way to save the report as a PDF (to the local filesystem) and then attach that as one of the attachments.

    Can anybody help me or guide me in the right direction please?

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  2. How to send filtered report via email
    By degras in forum Reports
    Replies: 4
    Last Post: 03-31-2011, 09:09 AM
  3. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM
  4. Replies: 9
    Last Post: 10-09-2009, 08:15 AM
  5. Replies: 1
    Last Post: 05-01-2009, 07:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums