Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 8 down vote accepted

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.

Update: As Mohith has pointed out, you can pass 250 Ids to MassEmailMessage vs 100 emails for the same message, again it depends your objects and features you need. If your 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 utlimatly its only dictating how many instances of each you pass in the array to the sendEmail, which ultimatly then governs overall what can be sent anwyay.

share|improve this answer

setTargetObjectIds method of MassEmailMessage accepts max of 250 Ids and setToAddresses of SingleEmailsMessage accepts 100 email address.This is what i would consider when designing.And also agreed with Andrew on his answer objects we focus matter while selecting

share|improve this answer

check out MassMailer app at http://www.mansasys.com/massmailer which will let you bypass salesforce mass email limits. Also check API at http://support.mansasys.com/support/solutions/articles/72737-mass-mailer-developer-guide

share|improve this answer
    
This is not an answer to the question. You may comment on questions and answers once you have enough rep. –  Peter Knolle Jul 27 '13 at 13:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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