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
IndeevarIndeevar 

Handling Messaging.SingleEmailMessage limit of 10

HI

There is a requirement to send emails to contact owners for birthdays of their

respective contacts. So we are calling  Messaging.SingleEmailMessage method within an Apex class

in a loop. But in the Apex class there is a limitation that this method cannot be called more

than 10 times. Contact Owners are more than 50 though. The loop runs this many times .

How to handle this governor limit issue?
RickyGRickyG
Why not use the sendMail method, which can accept an array of messages to send?  This will help to relieve the limit on the number of invocations, although the limit on the total number of messages sent a day will not be affected.

Hope this helps.
JimRaeJimRae
Rick,
Do you have a sample of using sendmail with an array?  I can't seem to get more than one message to get past into the sendmail function.