sendmail help

sendmail help

I am trying to create a function that will email out overdue notices to employees who have overdue items checked out. I want it to email out one email to each employee with a list of what they have that is overdue.

Currently, it sends out one email to the first person with an overdue item with everyone's overdue items in that one email. My current code is below.


void itat.sendEmailOverdue()
{
x = Checkout_Items [(Issued == "True" && Due_Date < zoho.currentdate)];
overdues = "";
for each x in Checkout_Items [(Issued == "True" && Due_Date < zoho.currentdate && Employee_ID =="e045608")]
{
overdues = overdues + "\n" + (x.Overdue_Email.getall());
sendmail
(
To : x.Email
From : zoho.adminuserid
CC : zoho.adminuserid
Subject : "Overdue Items"
Message : "<p>The following items are overdue. Please stop by at your earliest convenience to have them checked and reissued.<br />\n<br />\n<br />\n" + overdues + "<br />\n<br />\nSincerely,<br />\nJustin Bledsoe</p>"
)
}

}