Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access - Mass Emailing?

Tags:

ms-access

I'm using MS Access to create a database with over 5000 contacts. These contacts are separated up into which employee the contact belongs to, and then again into categories for easy searching. What I want to do is create a button that will open up a query in table form (simple), then have check boxes so an employee can select, for example, 100 contacts to send an email to out of the 110 in the table, and then send a mass email such as a newsletter (not so simple!). I've been going nuts trying to work out how to do this as I don't really understand programming (I'm a temp thrown into this job and just doing the best I can) and all I can find on the matter is something about loops (no idea!) and that I need software to do this.

Any solutions for me please? I'd like to avoid buying/installing software if possible and if you do have an answer, please make it as simple as possible...

Thanks in advance!

Kate


2 Answers

I have just created the following working example in MS Access 97.

A sample table (I tested the code with valid e-mail addresses):

ID Name Email

1 Rics [email protected]

2 Kate [email protected]

3 X [email protected]

A form with one button. The following code is being performed when the button is clicked:

Private Sub Mail_Click()

    Dim r As Recordset
    Dim email As String
    Set r = CurrentDb.OpenRecordset("select * from Addresses")
    Do While Not r.EOF
        email = r(2)
        DoCmd.SendObject acSendNoObject, Null, Null, email, Null, Null, "Test subject", "Message body of the test letter", False, Null
        r.MoveNext
    Loop
    r.Close

End Sub

I hope you could insert it into your application.

like image 95
rics Avatar answered May 15 '26 03:05

rics


Got it working :)

The code was great but it needed some tweaking to work specifically with my data. After a lot of errors popping up this is what I finally came up with:

    Dim r As Recordset
Dim Email As String
Set r = CurrentDb.OpenRecordset("select Email from FranksFinanceBrokers")
Do While Not r.EOF
    Email = Email & r(0) & ";"
    r.MoveNext
Loop
r.Close

DoCmd.SendObject acSendNoObject, Null, Null, "", "", Email, "", "", True, Null

End Sub

Thanks for ur helps guys!


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!