Using renderStoredEmailTemplate(templateId, whoId, whatId)
method of Messaging Class, we can send email to non-contacts using apex. Here is an example to send email to Opportunity owner.
Sample code:
//Send email to opportunity owner Messaging.SingleEmailMessage mail = Messaging.renderStoredEmailTemplate(emailTemplateId, ownerId, opportunityId); mail.setTargetObjectId(ownerId); mail.setSubject(mail.getSubject()); mail.sethtmlBody(mail.gethtmlBody()); mail.saveAsActivity = false; Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});