I've set up a server-side scheduled script to send out a daily notification email, and was horrified to observe as Filemaker Server sent over 500 emails to the designated email addresses. Of course I tested the solution using only my own email addresses, so no harm done, but I'd love to figure out what I'm doing wrong. Here's the setup:
1. Contract Table: This is a table of contracts, each of which has a field for "To," "Cc," "Bcc," "Subject" and "Email Body," for the purpose of crafting a custom notification for each Agreement record. Note that the user will more likely than not include more than one email address in the "To," "Cc," and "Bcc," fields.
2. Agreement Alert Table: The key fields in this table are: i) Notification Date (there may be multiple notifications per agreement); and ii) Notification Status. These two fields appear as a portal on the Contract Table layout.
3. The Script Process:
A. The script first searches among all of the records in the Agreement Alert Table for records which have a Notification Date that matches the current date, and which have a Notification Status of "Pending."
B. Assuming the search results in a found set, the script then loops through each Agreement Alert record to i) Send Mail based on the parameters from the related Contract Table (e.g., the "To," "Subject" and "Email Body" fields); and then ii) switch the Notification Status to "Sent. It exits after the last record.
C. The script is programmed to send out one email using data from the current records, and not collect addresses across the found set.
The result is hundreds of duplicate emails to each address in the "To," "Cc" and "Bcc" fields.
The database is being served via Filemaker Server 12 on a remote MacMini.
Thanks in advance for your insight!