Dear All,
I have a query the content of which I would like to send via email
I would like each UserID to receive only their records
I have the below code but the problem is that a mail gets created for each record and not for each UserID
And the code covers the To field only, I would also need the Body to get "grouped" by UserID
Could you please advise?
Many thanks in advance
I have a query the content of which I would like to send via email
I would like each UserID to receive only their records
I have the below code but the problem is that a mail gets created for each record and not for each UserID
And the code covers the To field only, I would also need the Body to get "grouped" by UserID
Could you please advise?
Many thanks in advance
Code:
Dim rstRecip As Recordset
Set rstRecip = CurrentDb.OpenRecordset("qry_emailing", dbOpenDynaset)
With rstRecip
Do While Not .EOF
ToField = .Fields("UserID")
Dim olapp As Object
Dim olns As Object
Dim olfolder As Object
Dim olitem As Object
Dim olattach As Object
Set olapp = CreateObject("Outlook.Application")
Set olns = olapp.GetNamespace("MAPI")
Set olfolder = olns.getdefaultfolder(6)
Set olitem = olapp.createitem(0)
Set olattach = olitem.Attachments
olitem.To = ToField
'olitem.CC = ""
olitem.Subject = "Absence approval request of "
olitem.body = "Please find below all the requests of "
'olattach.Add "c:\temp\cafeteria_rendszer.pdf", 1
olitem.display
'olitem.send
Set olitem = Nothing
Set rs = Nothing
Set db = Nothing
Set olfolder = Nothing
Set olns = Nothing
Set olapp = Nothing
.MoveNext
Loop
End With
rstRecip.Close
Set rstRecip = Nothing