One way to do this would be to set up a data area that your program changes when you find records that meet your criteria. If you find a record, update the data area with a “Y”. If no records are found, update the data area with a “N”. Before sending an email, check the data area. If it is “Y”, send the email. If it is “N” then do not send an email.
Another way would be to set up a counter in your program. Each time you find a record, increment the counter by one. At the end of your program, check the counter. If it is greater than zero, send the email.