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.
Pieter Wijnen - 12 Sep 2007 20:21 GMT
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
> William5271 had the same question I do:
>
[quoted text clipped - 6 lines]
> However, he didn't tell us how he figured it out. I'd love to hear how he
> did it.