Emailing from a query.

G

Guest

William5271 had the same question I do:

I need to send emails from an access database, but I want to send them from a
query so that I only email the certian people. Access says that it can't send
an email from a query.

However, he didn't tell us how he figured it out. I'd love to hear how he
did it.
 
P

Pieter Wijnen

You can build code on a recordset based on the Query

Something like

Public Sub EmailQuery()
Dim Db As DAO.Database
Dim Qdef As DAO.QueryDef
Dim Rs As DAO.Recordset
Dim ToList As Variant

ToList = Null
Set Db = Access.CurrentDB
Set Qdef = Db.QueryDefs("MyQuery")
Set Rs = Qdef.OpenRecordset(DAO.dbOpenSnapshot)

While Not Rs.EOF
ToList = (ToList + ",") & Rs.Fields("EMail").Value
Rs.MoveNext
Wend
Rs.Close : Set Rs = Nothing
Set QDef = Nothing
Set Db = Nothing
Access.DoCmd.SendObject bcc:=ToList, Subject:="The Specials",
MessageText:="A Message for you Rudi"

End Sub

HTH

Pieter
 

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