One Email Multiple Reports

Rich1968

Registered User.
Local time
Today, 08:22
Joined
Jan 24, 2003
Messages
57
I have been trying to set up a routine that makes reports based on a form. I have a macro that ques the reports. This works great for printing, but not for emailing

With the reports I want to email them to a customer. This works fine with one report but when I have more then one it only sends the last report. I was looking at printing to a file but all I get is junk.

I have attached my code. This code is set to an event procedure on my form. I know not very elagent but I'm not a pro at this. Any help would be appreciated.

I'm using Access 2003

Thanks
Rich De Gray
_______________________________________________________________

Private Sub cmdEmailReports_Enter()
On Error GoTo cmdEMailReports_Click_Err

Dim strMsg As String
Dim strTitle As String
Dim intStyle As Integer
Dim StrCriterion As String
Dim strMailto As String
Dim strDocName As String
Dim strMessage As String


'This forces the record to be saved.

If Me.Dirty Then
Me.Dirty = False
End If

'Me.Visible = False

StrCriterion = "[Customer Id]=" & Me![Customer ID]
DoCmd.RunMacro "Marketing Proposal"


strMessage = "Attached is our proposal we discussed"

'This will minimize the report, whilst the e-mail in being prepared, I have tried not to have it open in preview but
'cannot get it to work.

DoCmd.Minimize

strMailto = Forms!Marketing.

strDocName = "M C Client Cover Letter"
strDocName = "M C Client Welcome"
strDocName = "M C Lease What To Send"
strDocName = "M C Mission Statement"
strDocName = "M C Proposal Fee Explanation"
strDocName = "M C Proposal Procedures"
strDocName = "M C Proposal References"
strDocName = "M C Worthless Checks"
strDocName = "M C Agreement"
strDocName = "M C Set Up Invoice"

'This will create the e-mail

DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto, "", "", "Credit Management Services Of Georgia, LLC.", strMessage, True, """"

'This will close the report when you either cancel or send the e-mail. The Frm_Customer will open

DoCmd.Close acReport, "C Client Cover Letter"

cmdEMailReports_Click_Exit:
Exit Sub

cmdEMailReport_Click_Err:
MsgBox Error$
Resume cmdEMailReports_Click_Exit
End Sub
 
In order to include multiple attachments to an email, you need to use automation rather than SendObject:

http://support.microsoft.com/?kbid=161088

You would export each report to a file, then attach the file. Personally I'd use PDF. The reason you only get the last one is that these lines:

strDocName = whatever

overwrite each other, so you only get the last. You'd need to set the variable and export in turn.
 
Thanks PBaldy,

Now I need to bone up on Variables and exporting. I tried to output in a macro to a file in rich text but all I get is junk

Thanks for the help

Rich
 

Users who are viewing this thread

Back
Top Bottom