Results 1 to 3 of 3

Button with email report command - Email does not allow additional attachments

  1. #1
    Marlene23 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    14

    Button with email report command - Email does not allow additional attachments

    Good Day

    I found this piece of code and it does exactly what I need. It opens the email message in with the report attached as a .pdf, the problem I have is that it does not allow me to add any additional files to the email.



    Can anyone perhaps assist me as to why this is happening and if I need to amend the code?

    Code:
    Private Sub Command32_Click()
    On Error GoTo ErrorHandler
        Me.Dirty = False
        'This opens up the report based on the current view in the form
        DoCmd.OpenReport "Printing Order", acViewPreview, , "[OrderID] =" & Me.OrderID
        'This takes that open report and then attaches it to an email
        DoCmd.SendObject acSendReport, , acFormatPDF, Forms![frm_Add_Orders]![Email], Subject:="Printing Order: " & [EmailSubject]
        'Closes the open report after the email is sent.
        DoCmd.Close acReport, "Printing Order", acSaveNo
        MsgBox "Order Sent Successfully."
    Cleanup:
        Exit Sub
    ErrorHandler:
        Select Case Err.Number
        Case 2501
            DoCmd.Close acReport, "Printing Order", acSaveNo
            MsgBox "Email was cancelled."
        Case Else
            MsgBox Err.Number & ": " & Err.Description
        End Select
    Resume Cleanup
    End Sub

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,360
    You can't add multiple attachments with the DoCmd.SendObject method.

    You would have to investigate using either CDO or Outlook automation to create an email then add as many attachments you want to it.
    Searching on here or google will give you a start.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,440
    you may be able to get around this by zipping all the files into a single file before sending it as well. i.e. push out all the reports first, issue a shell command to zip the files together, then attach the file to the outgoing email.

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

Similar Threads

  1. Email command button coding needed
    By bradp1979 in forum Forms
    Replies: 3
    Last Post: 10-09-2015, 03:30 PM
  2. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  3. Command Button to Send Outlook Email
    By AJM229 in forum Forms
    Replies: 19
    Last Post: 05-07-2014, 09:05 AM
  4. Command button to open email template
    By avarusbrightfyre in forum Import/Export Data
    Replies: 5
    Last Post: 09-10-2011, 11:18 AM
  5. Send Report and Attachments in Email
    By Pimped in forum Programming
    Replies: 1
    Last Post: 06-21-2011, 02:51 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
  •  
Tech Forums: Microsoft Office Forums