Send a report to several addresses

  • Thread starter Thread starter Luis Marques
  • Start date Start date
L

Luis Marques

I have a report, subgrouped by client.

I need to send this report by mail, but each subgroup (client) must be
sended to a diferent address.

Can I do this with macros? I don’t have a lot of experience with VBA:

Thanks in advance.
 
Hello.

Check this code here:
Option Compare Database


Private Sub cmdMail_Click()

'**********************
'Developed by Mike Buraczewski
'Use for mailing list developement
'This code will e-mail a report to a list created from a multiselect list box.
'The listbox must be named "lstMailer"
'Populate the list in any manner


Dim MailList As String
Dim strTo As String
Dim strCCTo As String
Dim strBccTo As String
Dim strmsg As String
Dim Address As Variant
'Report variables
Dim strFilter As String
Dim rpt As String

'Create string for list of mail recipients
'lstMailer is a multiselect listbox
For Each Address In Me.lstMailer.ItemsSelected
MailList = MailList & ";" & """" & Me.lstMailer.ItemData(Address) & """"
Next Address
If MailList = "" Then
MailList = ""
Else
MailList = Right(MailList, Len(MailList) - 1)
End If
'**********************
'set report to print
rpt = "report1" 'report name goes here. This is the name of the report you
wish to send.
strFilter = "" 'add code to create filter for report if necessary

strTo = "(e-mail address removed)"
strCCTo = "" 'Additional email addreses go here
strBccTo = "" 'Additional blind email addrresses go here
strmsg = "" 'Default message content goes here

DoCmd.OpenReport rpt, acPreview, , strFilter
'The next line sends the report in RTF format.
'This can be changed to several formats, search the help file for acFormatRTF

DoCmd.SendObject acSendReport, rpt, acFormatRTF, MailList, strCCTo,
strBccTo, "Test of E-mail", strmsg, -1
DoCmd.Close
MsgBox "This form is incomplete." & vbNewLine & vbNewLine & "Modify the code
per the in-line comments", , "Send E-Mail"
Exit_cmdPrint_Click:
Exit Sub

Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub

Look in google for a file maned sendemail.mdb

I think it has what you want.

PS: Are you portuguese?
Marco
 
Back
Top