I’m trying to create a script to loop through the results of an SQL query and send an email out on a 1-per-line basis. It is a customer list where the customer needs to be updated on the status of their order.
The result set from the SQL query looks like this:
Subject,EmailAddress,Status (Header line from query result)
Sub1,example@example . com,New
Sub2,test@test . com,Aged
Sub3,test@example . com,Closed
Sub4,example@test . com,New
In this example, I would need to send out 4 separate emails.
Email #1:
To: example@example . com
Subject = “Sub1”
Body = “New”
Email #2:
To: test@test . com
Subject = “Sub2”
Body = “Aged”
Email #3:
To: test@example . com
Subject = “Sub3”
Body = “Closed”
Email #4:
To: example@test . com
Subject = “Sub4”
Body = “New”
Individually, I have no problem getting the results back from the query nor sending emails. I do not however know how to loop through the result set and send out all the different emails to the various recipients.
Any help or guidance would be greatly appreciated!