Email more than one report

bonekrusher

Registered User.
Local time
Today, 15:41
Joined
Nov 19, 2005
Messages
266
Hi All,

I am looking at being able to attach more than one report to an email (SendObject). I've search the forum and I am not having luck. This is what i have so far. I want to attach "report1" and "Report2" to the email.

Code:
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

    Dim stDocName As String
    Dim stDocname2 As String
    Dim Both As String
    DoCmd.SendObject acReport, "report1", acFormatRTF, "user@domain.com", "", "", "Audit Findings"
 

Exit_Command10_Click:
    Exit Sub

Err_Command10_Click:
    MsgBox Err.Description
    Resume Exit_Command10_Click
    
End Sub
 
Are you familiar with Outlook Automation?
 
a little. This codes emails any files I have in C:\temp. I just need to know how to combine them. aby ideas?

Code:
Private Sub cmdEmail_Click()
Dim Count As Integer
' ********** First place all of your files in an array **************
Dim DirectoryFiles()                ' This must be above Sub Main
ChDir "C:\temp\"        
ffile = Dir("*.*")
Do While ffile <> ""
     If ffile <> "" Then
          ReDim Preserve DirectoryFiles(Count)
          DirectoryFiles(Count) = ffile
          Count = Count + 1
     End If
     ffile = Dir()
Loop
' *************** Declare the Outlook object ***********
Dim objoutlook As Object
Dim loc As String
Dim path As String

loc = "c:\temp\"
Dim objoutlookmsg As Object
Set objoutlook = CreateObject("Outlook.application")
Set objoutlookmsg = objoutlook.CreateItem(0)
With objoutlookmsg
  .To = "xxx@xxx.com"
  .Subject = "Test attach files"
  .Body = "Attachment added"
  ' ****** Add as many files as were stored ****
  For i = 0 To UBound(DirectoryFiles())
  path = loc & DirectoryFiles(i)
    .Attachments.Add path
  Next

  '.Send
End With
Set objoutlook = Nothing
Set objoutlookmsg = Nothing
End Sub
 
You mean, so 2 reports become 1 attachment?

You would have to combine them onto 1 file, I think?
Maybe using Word automation.
I've tried this a little, but can't retain the formatting that was in the original report.
But I can consolidate several reports, onto 1 Word doc.

Is this an option?
 
DB7,

I was just trying to email 2 reports, not combine them. I don't know if its possible. No one seems to have an answer.
 

Users who are viewing this thread

Back
Top Bottom