20

I'm scoping out a project that will involve sending outbound email messages, and I'm a little confused about why one would use a MassEmailMessage instead of multiple SingleEmailMessages.

If you look at the documentation, Singles have far more options available when it comes object types that can be used in the setWhatId methods, especially since they can accept Custom objects. Mass emails have very limited options for the setWhatIds.

SingleEmailMessage: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_single.htm

MassEmailMessage: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_mass.htm

Single and Mass emails have separate limits, but they both have the same limit of 1,000 external email addresses per day.

And when it comes to using the Messaging.sendEmail(), you have pass in an array of messages anyway, so why not send in an array of many Singles instead of an array of one Mass?

So what am I missing? What's the advantage of using a MassEmailMessage for sending out a batch of emails when the SingleEmailMessages have more options?

19

What MassEmailMessage appears to give you is a more optimal coding route if you are focusing on sending to Contacts, Leads or Users relating to either Contract, Case, Opportunity or Product objects.

So if you had 50 such Contacts to email you need only have a single MassEmailMessage instance and set a list of those Id's into it. Instead of creating 50 SingleEmailMessage instances each setup accordingly (you'll have to pull the email addresses yourself) to achieve the same. So there is arguably a marginal heap and statement benefit as well. As you say there are quite a few more features on the SingleEMailMessage, but if you don't need any of those perhaps the MassEmailMessage has a place.

If you scaling above my earlier example of 50 and working with these objects, this is indeed an additional benefit to those I've described above. Though ultimately its only dictating how many instances of each you pass in the array to the send email, which ultimately then governs overall what can be sent anyway.

| improve this answer | |
  • 1
    Is this still current in 2020? I cannot find any documentation on this (250 mass / 100 single mails per invocation)? All I can find regardin email sending is this help.salesforce.com/… and this help.salesforce.com/… but both don't say anything about these limits (only about 5000 total per day) – Christoph Apr 7 at 12:19
  • @Christoph No the 250 vs 100 no more apply. It's now 5000 emails per org per day for the external email Ids. For internal users, there is no limit! – Mohith Shrivastava 22 hours ago
7

setTargetObjectIds method of MassEmailMessage can accept an Array of ID for contact, lead and user id's, while you will need to create individual elements for the Array of SingleEmailMessage. However SignleEmailMessage allows you to pass any external email address.

So there is a Heap gain if you prefer to send emails to Salesforce Leads, Contacts, or users via the MassEmailMessage and is efficient.

However, if you are sending emails to external users both of these have a max limit of 5000 external emails per day per org.

Note that limits only apply if you are sending them to external emails. For Internal users, there is no limit and you can send unlimited emails.

You can monitor using the workbench REST utility via limit API and checking MASS EMAIL and SINGLE EMAIL limits.

The Mass email limits are described here

/services/data/v48.0/limits
| improve this answer | |
  • Hi Mohit, is the 250 Ids limit on one emailMessage instance? is there a limit on the number of MassEmailMessage instances I can create? – akash Jan 23 '15 at 9:57

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.