function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anschoeweanschoewe 

How to ensure emails to internal users do not count against email limts?

We send numerous emails to numerous internal Salesforce users for things like job failures in Apex.  We always assumed that setting the toAddresses() field to the email address of an internal user (ie. first.last@mycompany.com) would qualify as an internal email.  After hitting some limits, I'm questioning that assumption. It appears that sending an email like this will still qualify as an external email even though there is a internal Salesforce user with that email.  Can someone please confirm?

 

Should we instead use setTargetObjectId(internalUserId) to guarantee the email as counted as an internal address and will not count against our limit?  If so, how do we send to numerous internal users at the same time?  Messaging.SingleEmailMessage only has the singular method setTargetObjectId() and not the plural version setTargetObjectIds().

 

Any clarification is appreciated.

 

Andrew

 

Messaging.SingleEmailMessage emailMsg = 
     new Messaging.SingleEmailMessage();  
emailMsg.setTargetObjectId(internalUserId);
//must be false if sending to internal user    
emailMSg.saveAsActivity = false; 
emailMsg.setSenderDisplayName('sender name');  
emailMsg.setSubject('some subject');  
emailMsg.setBccSender(false);  
emailMsg.setUseSignature(false);  
emailmsg.setPlainTextBody('email body');  
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailMsg });

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

I believe that's correct. You'll have to create multiple copies of the email and set the target object ID to each recipient user. You can send several mails at once, just add them all to a List<SingleEmailMessage>.

All Answers

sfdcfoxsfdcfox

I believe that's correct. You'll have to create multiple copies of the email and set the target object ID to each recipient user. You can send several mails at once, just add them all to a List<SingleEmailMessage>.

This was selected as the best answer
Chirag MehtaChirag Mehta
To add, please note :
  • setTargetObjectId to Contact does count in limit
  • setTargetObjectId to User does NOT count in limit.