0

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.

  • What kind of org are you testing this in? If a developer org, I think the limits are much lower. My Google-fu is failing me to find the limits right now. – Daniel Hoechst Apr 4 '14 at 19:19
  • Well I'm testing this in Dev Org, but they say if Dev org is newer than Winter'12 then only the limit is 15 emails, but for older orgs It is kind of like 1000 emails per day. Mine is over 4 years old. Also, another thing is, the error popups only when I select records 15 and higher, if I select lower than 10, say, 6 records, I cans end emails perfectly fine without any issues and any number of times. So I'm kind of sure that the error as such is not what is throws in the message :( – VarunC Apr 4 '14 at 19:23
  • Doesn't matter when the org was created. You'd still be limited to 15 email addresses. The limits are always enforced for the version your org is running. Note that it is email addresses and not emails. I think this means you can send multiple emails to the same email address as long as you don't do more than 15 unique ones. – Daniel Hoechst Apr 4 '14 at 19:25
  • Ah, ok. that might be the case, in my test all 15+ emails are same. I'll test with different addresses and see what my results are. – VarunC Apr 4 '14 at 19:29
1

In developer orgs, you are limited to send single emails to 15 email addresses (see footnote at the very bottom of the page). I think this means 15 unique email addresses, so you could send emails to the same email address multiple times, but not to more than 15 unique email addresses in one day. In prod and sandboxes, you can do 1000 emails.

  • I believe this is the issue. DE orgs by default have an almost comically low email limit. You may be able to get it increased via the partner portal (if you're a partner). See salesforce.stackexchange.com/a/24692/60 – ca_peterson Apr 4 '14 at 21:43
  • Ok, I'm waiting for my partner support to have the limit increased, during this time I've confirmed that I am able to send 15 emails only. Not more than this number. I'll update the thread as soon as I can test run a high number of emails in batch once limit has been raised. – VarunC Apr 7 '14 at 9:42
1

There is a limit of 10 sendEmail methods per request. Sounds like you might have buffering enabled in your remoting call.

JavaScript remoting optimizes requests that are executed close to each other in time and groups the calls into a single request. This buffering improve the efficiency of the overall request-and-response cycle, but sometimes it’s useful to ensure all requests execute independently.

The default configuration is

{ buffer: true, escape: true, timeout: 30000 }

Try changing the buffer to be false

{ buffer: false, escape: true, timeout: 30000 }
  • According to the question he's only making one call with a list argument. If buffering were the issue there would have to be 10 seperate calls buffered together to cause this,which sounds a bit unlikely (although possible) – ca_peterson Apr 4 '14 at 19:07
  • Yes. I'm only initiating single JS Remoting call and in that call, I'm sending Multiple Emails via single sendEmail() function call initiation. More troubling for me here is, the Error Message. Why this "SINGLE_EMAIL_LIMIT_EXCEEDED, Failed to send email" error, there isn't any error as such in Browser's Console Window either. – VarunC Apr 4 '14 at 19:16
  • 1
    Yep, misread question. Carry on, nothing to see here... – Daniel Hoechst Apr 4 '14 at 19:20

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.