+ Start a Discussion
Keaton KleinKeaton Klein 

MassEmailMessage error

I have a trigger which uses mass email message to send to a list of leads.  It works great when leadids is populated with 5 or 6 IDs but if it is populatd with 7 or more i get the error message stating MASS_MAIL_LIMIT_EXCEEDED, Failed to send email: []

It is my understanding that we can use mass email to send to a list of up to 250 leads/contacts.  Any thoughts on why i am being limited to 6?  Below is a snippet from my code.

Also, when the emails are sent it shows up under Activity History but it does not show up under HTML Email Status so i cannot see if the email was opened by the recipient.
 
if (LeadIds != null && !LeadIds.isEmpty())
            {
                	Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();

                	string etidasstring = a.ezwf__Email_Template_ID__c;
                     
                    mail.setSenderDisplayName(UserInfo.getName());
                    mail.setReplyTo(UserInfo.getUserEmail()); 
                    
                    mail.setTargetObjectIds(LeadIds); 
                    mail.setTemplateId(etidasstring);
                    mail.setSaveAsActivity(true); 
                     
                    Messaging.sendEmail(new Messaging.MassEmailMessage[] {mail});
            }

 
Best Answer chosen by Keaton Klein
Balaji BondarBalaji Bondar
Hi Kearon,

you create a list for email messages.Create your emails, one by one (maybe in a loop) and add them to that list. Finally you do a Messaging.sendEmail(yourList)
 
List<Messaging.SingleEmailMessage>  myEmails = new List<Messaging.SingleEmailMessage>();

//repeat this paragraph as often as you like
Messaging.SingleEmailMessage oneEmail = new Messaging.SingleEmailMessage();
    //specify details of oneEmail here
myEmails.add(oneEmail);

//now send them

Messaging.sendEmail(myEmails);

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.

All Answers

Balaji BondarBalaji Bondar
Hi Kearon,

you create a list for email messages.Create your emails, one by one (maybe in a loop) and add them to that list. Finally you do a Messaging.sendEmail(yourList)
 
List<Messaging.SingleEmailMessage>  myEmails = new List<Messaging.SingleEmailMessage>();

//repeat this paragraph as often as you like
Messaging.SingleEmailMessage oneEmail = new Messaging.SingleEmailMessage();
    //specify details of oneEmail here
myEmails.add(oneEmail);

//now send them

Messaging.sendEmail(myEmails);

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
This was selected as the best answer
Keaton KleinKeaton Klein
Thanks Balaji, I using this method does the trick.  Any thoughts on my it shows up under Activity History but not under HTML Email Status.  I would like to be able to see if/when the message was been opened by the receiver.