3

I have been looking for some time looking for a way how can error SINGLE_EMAIL_LIMIT_EXCEEDED Email limit exceeded be avoided if I need to send one simple email to one single user, for example, myself.

15 Email invocations limit on Developer Edition is a very small number, and it is usually quickly exceeded. Using Workflow Email Alerts may help to send more emails but still it is limited.

6

Looks like I have found an answer very long time back but didn't write it down. So today I started investigating this again and decided to store the solution found somewhere.

It is interesting that this documentation has a small sentence answering this question. https://help.salesforce.com/apex/HTViewSolution?id=000002490&language=en_US

Emails sent using setTargetObjectId() set against the user object do not count against the SingleEmailMessage limit.

It is very interesting that if I run this code

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses( new List<String>{'julfy@i.ua'} );
mail.setSubject( 'test 2' );
mail.setHtmlBody( 'test 2' );
Messaging.sendEmail( new Messaging.SingleEmailMessage[] { mail } );

it fails with error

Line: 14, Column: 1 System.EmailException: SendEmail failed. First exception on row 0; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: []

while if I execute the code

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId( UserInfo.getUserId() );
mail.setSaveAsActivity( false );
mail.setSubject( 'test 2' );
mail.setHtmlBody( 'test 2' );
Messaging.sendEmail( new Messaging.SingleEmailMessage[] { mail } );

I see no errors.

Looks like someone else also has mentioned this here: https://salesforce.stackexchange.com/a/17143/3716

However, that answer is undervoted and doesn't appear on the top on googling.

3
  • Are you referring to @Ashwani answer to that question or to the accepted answer? If you copy the link on the "share" button, you get a link to the specific answer you're referring to for the question. I show a different link that what you've posted, even though yours takes me to his answer is why I ask. – crmprogdev Jul 7 '16 at 15:31
  • I meant Ashwani answer, not the accepted one – Patlatus Jul 7 '16 at 15:43
  • @crmprogdev I meant Ashwani answer, and I believe I have put the correct link: salesforce.stackexchange.com/a/17143/3716 – Patlatus Jul 7 '16 at 15:45

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.