Automatic emails

G

Guest

I have a table in Access that contains the recipients name, email address and
a check box. Does anybody know how to send an automatic email (after the
user clicks a command button) to all recipients that have their corresponding
checkbox checked with a message entered from another table? Thanks in
advance.
 
P

pietlinden

I have a table in Access that contains the recipients name, email address and
a check box. Does anybody know how to send an automatic email (after the
user clicks a command button) to all recipients that have their corresponding
checkbox checked with a message entered from another table? Thanks in
advance.

open a recordset based on the query that returns the records you want.
loop through the recordset, sending an e-mail to each. (Use SendObject
or CDOSys).

AIR CODE...


dim rs as DAO.Recordset
set rs=DbEngine(0)(0).OpenQuerydef("Name_of_your_query")

do until rs.EOF
DoCmd.SendObject rs.Fields("EMail"), strMessage,
strPathToAttachment
rs.MoveNext
loop

rs.close
set rs=nothing
 
D

DocBrown

Is there a way to generate a 'To' or 'CC' list so I only send one email to
all the recipients that have been selected by the query?

John S.
 
S

Stuart McCall

DocBrown said:
Is there a way to generate a 'To' or 'CC' list so I only send one email to
all the recipients that have been selected by the query?

Debug.Print CurrentProject.Connection.Execute _
("SELECT EmailAddress FROM SomeTable").GetString(2, ,";")

Replace 'EmailAddress' and 'SomeTable' with your actual names. This will
generate a semicolon-delimited list of email addresses, which is what you
need to feed into your TO field (whichever mailing method you use).
 

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