0

I'm trying to find the best way to handle an issue. I have some WFRs and Processes built off the Case object that update the related Account. One of the WFRs sends an email alert at the end of the day compiling all the open cases in the email message from that day.

The template is a VF page that provides a list of the Cases in 1 email. I want to send this alert to any Contacts related to the Account who are marked as a Business contact in a custom checkbox field on the Contact level. There really is no limit on how many contacts per Account this might be, but could be anywhere from 1-20. I know there is a limit for Apex on sending more than 10 emails.

Does anyone know the best way to handle this situation? I thought about creating lookup fields on the Account and populating when a Contact record is edited, but this just doesn't seem to be the most efficient way.

4

Yes you can send email from apex

EmailTemplate templateId = [Select id from EmailTemplate where name = 'Your template Name'];
List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
for(contact con : contactList)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateID(templateId.Id); 
mail.setTargetObjectId(con>id)
mail.setSaveAsActivity(false);
allmsg.add(mail);
}
Messaging.sendEmail(allmsg,false);

Basically add all contact in the list and then send them in single shot. In one time you can send 100 emails. So this will solve your problem.

| improve this answer | |
  • Thanks! Do I need to do this as a trigger or can i just create a Class and call that from a Process? – J. Neilan Jun 15 '16 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.