Results 1 to 2 of 2
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Attaching Report To Email

    Hi

    Code:
    Private Sub Command15_Click()Dim oApp As New Outlook.Application
    Dim oEmail As Outlook.MailItem
    Dim fileName As String, todayDate As String
    Dim Date1 As String
    Dim Date2 As String
    Dim obj As Object
    Dim rep As String
    
    
    Date1 = Format(Text10, "DD-MM-YYYY")
    Date2 = Format(Text12, "DD-MM-YYYY")
    todayDate = Format(Date, "MMDDYYYY")
    'fileName = Application.CurrentProject.Path & "\Performances From " & Date1 & " To " & Date2 & ".pdf"
    'DoCmd.OutputTo acReport, "Performances", acFormatPDF, fileName, False
    
    
    'Email the results of the report generated
    Set oEmail = oApp.CreateItem(olMailItem)
    With oEmail
        .Recipients.Add "user@gmail.com"
        .Subject = "Lecturer Performances From " & Date1 & " To " & Date2
        .Body = "Dear Staff Members" & vbNewLine & "I here with attach the performane report of lecturers from " & Date1 & " to " & Date2
        .Attachments.Add fileName
        .Display
        '.Send
    
    
    End With
    
    
    MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"
    End Sub

    I used above code to send attachment as email, but when i run the code it saves a copy of the report in my desktop. is there is way to remove highlighted area and import the report as pdf from database directly?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can use SendObject which won't save a copy. Failing that, use Kill to delete it after.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 12
    Last Post: 08-18-2017, 05:13 PM
  2. Replies: 7
    Last Post: 08-01-2017, 06:38 PM
  3. Attaching Spreadsheet to email without saving it
    By MTSPEER in forum Import/Export Data
    Replies: 3
    Last Post: 10-11-2016, 10:00 AM
  4. attaching files to an email via a MACRO
    By bobandtom in forum Macros
    Replies: 22
    Last Post: 10-29-2013, 10:25 AM
  5. Replies: 4
    Last Post: 04-13-2011, 10:11 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