Email list

K

Kathy Webster

I have a contacts table with an email field in it.
How can I send an email blast to everyone in the table?

Tia,
kw
 
K

Kathy Webster

That's a little scary for me, Mr. Feakazeud. I'm familiar w/the SendObject
part, but the looping part is over my head. Can someone baby me a little?
kw
 
F

freakazeud

Hi,
I'm going to comment almost each line for you so you know what is happening.
Just put this on the on click event of a form button if that is where you
want to execute it from.

--------------------------------------------------
'Declaire Variables
Dim rs As New ADODB.Recordset
Dim strEmail As String

'Open ADO recordset change YourEmailTable to the name of the table or query
holding your emails
rs.Open "YourEmailTable", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic

'Clear strEmail Variable
strEmail = ""

'Start to loop through the recordset
Do While Not rs.EOF

'Build email string...change "emails" in "rs!emails" to the name of the
field in the table/query you specified earlier which holds the email address
strEmail = strEmail & rs!emails & ";"

'move to next record in recordset...go to beginning of loop and add the next
email of that record to the email string (strEmail)
rs.MoveNext
Loop

'Send email using SendObject...the "To" argument will be filled with the
values the constructed string "strEmail" holds
DoCmd.SendObject , , , strEmail, , , "test", "Test", True

'Close established references...clean up code
rs.Close
Set rs = Nothing
 
K

Kathy Webster

Wow, thank you for commenting each line!
I'll try this in the morning when my head is more clear :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top