Send Email To Contacts from a Table

Dhamdard

Dad Mohammad Hamdard
Local time
Today, 23:53
Joined
Nov 19, 2010
Messages
103
Hello folks,

I am doing a payroll and leave database for an office for free. I am asked to create a button on the payroll form to send an email and an attached snapshot of their respective payroll to each employee separately. List and email address of people who should receive the email is in a table. I can do it to send it to a single staff member only after each click. But I can't figure out any way to send emails to all staff members individually through a single click.

Looking forward for you help.

Regards,
Dad
 
You can open a recordset on your table and loop it to collect emailadresses.

Basic concept:

Code:
Sub SendPayroll()
Dim rs As DAO.Recordset
Set rs = Currentdb.OpenRecordset("Select * from MyTable Where ??")
If rs.RecordCount > 0 Then
   rs.MoveFirst
      DoUntil rs.EOF
        'code to send email
      rs.MoveNext
      Loop
End If
End Sub

Edit:
To access data in the recordset use:

rs!FieldName

ex:

rs!Emailadress

JR
 
Last edited:
Thanks very much, JR. It is exactly what I dreamed for.
 

Users who are viewing this thread

Back
Top Bottom