
2 answers
The Messaging Apex class (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm) has all the methods you need to send emails.
You could implement this ina batch class, but keep in mind that a standard org has a 5,000 mail limit per day - so if you have more than 5,000 contacts, it will still fail.