Send emails only to the contacts of the accounts when possible..

What should I do to send an email only to the contacts of the account if there are contacts linked to the accounts and o the accounts if the contacts linked to them are missing?