1

Below links says we can send up to 100 recipients for the To field in Salesforce.

https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_email.htm

Is it still 100 if I use settargetObjectId in singleEmailMessage? In my case SetTargetobjectId is ContactId.

I need to send 300 emails in singleemailmessage and I can't use MassEmailMessage as I cannot set WhatID to customobjectId in Massemailmessage.

Only contracts, cases, products and opportunities allowed for whatIds in MassEmailMessage

List<contact> lstcon=[Select Id,Name,Email,RecordTypeId,RecordType.Name From Contact where RecordType.Name = 'Customer'];
 List<Id> lstids= new List<Id>();
 for(Contact c:lstcon)
 {
  lstids.add(c.id);
 }
 EmailTemplate et=[Select id from EmailTemplate where name = 'CustomerTemplate' limit 1];

List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
for(Integer i=0; i<lstids.size();i++ )
{
If(lstids[i]!=null)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(lstids[i]);
mail.setTemplateId(et.Id);
mail.setWhatId(customobjectId);
mail.setsaveAsActivity(true);
mailList.add(mail);
}
}
Messaging.sendEmail(mailList);
2

Short answer is yes. You can use it. When we use setTargetObjectId you can send email to 100 recipients.

Also the 100 mail you are mentioning is for toAddress basically it means create a list add 100 email address in that and then you can use that in SettoAdresses

from the docs

You can specify up to 100 recipients for the To field and up to 25 recipients for the CC and BCC fields in each SingleEmailMessage.

  • Thank you @Tushar Sharma. Is there a way that I could set whatid to custom objectId in massemailmessage. – sfdc Aug 2 '17 at 16:21
  • @sfdc I don't think that's possible. You can still post a new question and maybe someone know any hack. – Tushar Sharma Aug 2 '17 at 16:28

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.