I've implemented a JS Remoting function that accepts a Set of ID values as input. For all the ID values I loop around in code and use:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
For each record I generate a PDF from a Visualforce page add it to the "mail" object record as:
Messaging.EmailFileAttachment fileAttachment = new Messaging.EmailFileAttachment();
at the end of the function. After I've looped around all records and generated a List<Messaging.SingleEmailMessage>
messages I then use following code to send out emails in bulk Messaging.sendEmail( mailinglist )
The thing is, if I select 4-5 records, it works fine and sends out emails. But if I try to send out emails in acecss of 15-20, I get this error message:
error: SINGLE_EMAIL_LIMIT_EXCEEDED, Failed to send email: []
Now, this error is unique to cases when daily limit of sending emails has axceeded, right? i.e. around 1000 emails a day: Salesforce App Limit Cheatsheet
I want your expert opinions about if there is a limit on JS Remoting such that it will prevent sending emails like this?
I know that using Messaging.SingleEmailMessage
, we can send 100 emails in single Messaging.sendEmail()
function call.