make a form, with a listbox , lstEmails. (connect the list to the mail list table)
put a list box/or combo to select a report
put a button to scan the list of emails to send the chosen report
The button would execute : ScanAndEmail in the button ON CLICK event
Code:
'------------
Public Sub ScanAndEmail()
'------------
Dim vTo, vSubj, vBody, vRpt
Dim vFilePath
dim i as integer
For i = 0 To lstEAddrs.ListCount - 1
vRpt = lstEAddrs.ItemData(i)
lstEAddrs = vRpt
vTo = lstEAddrs.Column(2)
vBody = "body of email"
vSubj = vRpt
vFilePath = "" 'path of the snapshot or XL or PdF
Call Email1(vTo, vSubj, vBody, vFilePath)
Next
End Sub
'-------
'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!! checkmark OUTLOOK OBJECT LIBRARY in the vbE menu, Tools, References
'-------
Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody,optional ByVal pvFile) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
vRpt = forms!frmRpts!cboRpt
With oMail
.To = pvTo
.Subject = pvSubj
.Body = pvBody
'USE THIS FOR SENDING THE REPORT IN THE BOX
DoCmd.SendObject acSendReport, vRpt, acFormatPDF, pvTO, , , pvSubj, pvBody
'USE THIS FOR ATTACHEMENTS
If Not Ismissing(pvFile) Then .Attachments.Add pvFile, olByValue, 1
.Send
End With
EmailO = True
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume Next
End Function