Ok, Bev. Here is what I would do.
1. Create a Query that includes the email address of the people that you
need to send this message to. My guess is that it would look something like
(you get the idea)
SELECT E.EmpID, E.EmpEmail, Count(A.ActionID)
FROM tblEmployees as E
INNER JOIN tblActions as A
ON E.EmpID = A.EmpID
WHERE A.ActionStatus = 'Pending'
Group by E.EmpID, E.EmpEmail
Now, in your code, open a recordset with this query as the recordsource.
Set rs = currentdb.openrecordset("qryEmpWPendingActions")
Create a loop, and loop through each of these employees. Then create
another recordset that gets the info from tblActions that you want in your
message and create the text message (or at least the bulk of it from that
recordset). Finally, use SendObject to send this one email with the
information that is specific to them. Untested sample follows.
Dim strSQL as string
Dim strMsgStart as string
Dim strMsgDetails as string
Dim rsDetails as DAO.Recordset
strMsgStart = "Whatever you want to say up front" & vbcrlf & vbcrlf
While not rs.eof
strSQL = "SELECT * FROM tblActions " _
& "WHERE [EmpID] = " & rs("EmpID") _
& " AND [ActionStatus] = 'Pending' " _
& " ORDER BY [ActionSuspense]"
set rsDetails = currentdb.OpenRecordset(strsql, , dbfailonerror)
strMsgDetails = ""
While not rsDetails.Eof
strMsgDetails = strMsgDetails & vbcrlf _
& rs("ActionDesc")
rsDetails.Movenext
Wend
rsDetails.close
docmd.SendObject acSendNoObject, , , rs("EmpEmail"), , , _
"Pending Actions", _
strMsgStart & strMsgDetails
rs.movenext
Wend
rs.close
set rs = Nothing
Beverly Darvill said:
Dale
I am able to do what you suggested and send as an attachement with no
problem - very easy macro to write - however we have trouble with people here
not opening attachments and that is why we want to (for want of a better
word) paste the format of the report into the body of an email, and also for
it to seperate out the actions and only send the appropriate actions to the
appropriate people i.e. Joe Bloggs only sees his actions whil Fred Smith sees
his without us have to go through approximately 100 possible actionees
individually.
Thanks