Results 1 to 3 of 3
  1. #1
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186

    Attach to Outlook a PDF report created from DoCmd.OutputTo

    Hi everyone,



    I have coded a button that creates a pdf file from a Report with DoCmd.OutputTo
    The issue I have is that I want to attach this new file to an Outlook email; Does somebody knows how?

    This below is my code

    Your support is highly appreciated!!!

    **********************

    Dim stDocName As String
    Dim stReportName As String
    Dim stFileName As String

    stDocName = "Diagram"
    stReportName = "Diagram AB "


    stFileName = CurrentProject.Path & "" & stReportName & Me.ID & ".pdf" 'set the file name for the new PDF

    DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, stFileName, True 'HOW Can I attach this to Outlook automatically?
    DoCmd.SendObject acSendReport, stDocName, acFormatPDF, , , , "NC Report: " & Me.ID, "NC Report with ID: " & Me.ID

    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    As already indicated in your other thread, use Outlook Automation. This is a common topic and should find many examples of code.

    Also described is an alternative that requires code to open report in design view, set Caption property, save report with this design change, then run SendObject. The PDF will be generated and named with the Caption property.
    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.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    OutputTo does not attach to emails.
    SendObject does.

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

Similar Threads

  1. DoCmd.SendObject Stops Macro When Report is not Created
    By Oxygen Potassium in forum Access
    Replies: 2
    Last Post: 09-22-2016, 06:53 AM
  2. Replies: 1
    Last Post: 07-30-2015, 12:56 PM
  3. DoCmd.OutputTo
    By tylerg11 in forum Reports
    Replies: 2
    Last Post: 08-09-2012, 12:22 PM
  4. DoCmd.OutputTo not working
    By arunkumar213 in forum Access
    Replies: 1
    Last Post: 09-08-2011, 10:41 PM
  5. AcFormat in DoCmd.OutputTo
    By SIGMA248 in forum Programming
    Replies: 1
    Last Post: 04-15-2011, 08:50 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