Sending Objects via Email to Multiple Recipients using Macro

rob3

New member
Local time
Today, 20:52
Joined
Jun 4, 2016
Messages
3
Hi everyone,

Fairly new to access and trying to work bits out but am stuck with emailing an object from my database. I am not great with VBA code so do most things using the macros. I can send an object from Access via email using an object ok but what I am having issues with is making access automatically populate the 'To' field in the macro with email addresses from a table.

I have a table called 'Emails' and the only field is 'Email Addresses' and the table has a collection of different email addresses.

I want to use a macro to send an object from my database, but when it creates the email, I want it to populate the 'To' field with every email address in the 'Emails' table. I want to do it this way so that a user can add or delete email addresses from the table, effectively managing it as a distribution list. I won't be the end user so it needs to be simple.

I have done lots of searching on forums, and found some VBA code which I have made work on my computer ok, but when I test the database on other computers, it doesn't appear to add the object to the email. The only difference I can think of is that when I put the VBA code in, I went into references and added the Outlook library. I need a solution that doesn't require that and ideally using a macro so it's more simple...

Any help is appreciated.

Thanks,
Rob
 
What object? a report -yes, a combobox , no.
sending:
in a form, put a list box, called lstEmails ,connected to the table.

a button to open the table for users to add/delete
docmd.opentable "tEmails"

another list box to select the report to send.
a text box for subject.

a button to send the emails,
Code:
'------------
Public Sub ScanAndEmail()
'------------
Dim vTo, vSubj, vBody, vRpt
Dim vFilePath
dim i as integer


vRpt = lstRpts
vBody = "body of email"
vSubj = txtBoxSubject


     'scan the list box to send report
For i = 0 To lstEmails.ListCount - 1
   vTo = lstEmails
   lstEmails = vTo     'visibly move list down
     
      'send email
   DoCmd.SendObject acSendReport, vRpt, acFormatPDF, vTO, , , vSubj, vBody
Next
End Sub
i would also add Name to the tEmail table.
 
it opens the outlook application while attaching the PDF report, can we also send the email automatically?
 

Users who are viewing this thread

Back
Top Bottom