alexfwalker81
Member
- Local time
- Today, 01:59
- Joined
- Feb 26, 2016
- Messages
- 107
The code below isn't functioning as I expected it to... In short, I've added in the 'While Not rs. EOF', down to 'Wend', in the expectation that it would loop through all the records in my query and drop them all into the text body of the email that I'm sending. Oddly though, the only record that comes through on the email is the final one in the query.
Any pointers?
Any pointers?
Code:
Public Function SendEmailStatus()
'If Format(Time(), "HH") = "08" And Format(Time(), "MM") < "30" Then
If DCount("[SKU]", "qry_status_monitor_email") > 0 Then
Dim rs
Dim db As DAO.Database
Dim mail As CDO.MESSAGE
Dim config As CDO.Configuration
Set db = CurrentDb
Set rs = CurrentDb.OpenRecordset("qry_status_monitor_email")
Set mail = CreateObject("CDO.Message")
Set config = CreateObject("CDO.Configuration")
config.Fields(cdoSendUsingMethod).Value = cdoSendUsingPort
config.Fields(cdoSMTPServer).Value = "10.0.0.102"
config.Fields(cdoSMTPServerPort).Value = 25
config.Fields.Update
Set mail.Configuration = config
With mail
.To = " blah "
.From = " blah "
.Subject = "Availability Status"
While Not rs.EOF
.TextBody = rs.Fields("sku") & " " & rs.Fields("description") & " " & rs.Fields("qty") & " " & rs.Fields("relevantstatus") & " "
rs.MoveNext
Wend
.Send
End With
End If
Set config = Nothing
Set mail = Nothing
'End If
End Function