What may help you understand it is the local declarations of
Client client;
One declaration is in loop, the other is in sendEmail.
You can also use two global declarations, like
Client sclient;
Client cclient;
Then use those in the appropriate places.