1

I have increased the limit of single email messages in one of my test orgs to 500 via creating a case with salesforce. My problem is that I am still not able to send out more than 50 to 60 mails. The mails sent as

setTargetObjectId(userId)

setSaveAsActivity(false)

My functionality is that on some specific actions of a user in my application, an email to other users is triggered by using the SingleEmailMessage object. These emails are all added in a list of Messaging.SingleEmailMessage and the sendEmail method is called only once per transaction.

What I am not able to figure out is that why the mails stop coming after 50 to 60 emails. If i check the debug logs I do see the EMAIL_QUEUE entry. There is no record of the mails in the Emails logs if I download them

I want to know is there a fair usage policy that salesforce enforces if it sees too many emails going out, since I see that the limits are still there (looking into the limits url in the workbench REST explorer)

Update :

List<Messaging.SingleEmailMessage> mailList=new List<Messaging.SingleEmailMessage>(); 
for(CustomObject__c c : someList) 
{ 
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();     
    mail.setSubject('Some sample subject'); 
    mail.setHtmlBody('some sample email body'); 
    mail.setTargetObjectId(c.user.Id); 
   //user is an object of User in salesforce mail.setSaveAsActivity(false);     
    mailList.add(mail); 
} 
List<Messaging.SendEmailResult> results = Messaging.sendEmail(mailList);
4
  • it would be great if you could post the code here
    – Samir
    Nov 28, 2016 at 12:36
  • I am sorry the code above is jumbled up...let me clean it up Nov 28, 2016 at 12:44
  • Edit your post and add the code
    – Raul
    Nov 28, 2016 at 12:45
  • Added the code in the comment. I am not able to format it but I guess it is readable as I am not doing much in it. Nov 28, 2016 at 12:52

3 Answers 3

1

You could refer these methods in your controller

Limits.getEmailInvocations() //number of email invocations that have been called.
Limits.getLimitEmailInvocations() //total number of email invocation that can be called.

In case the limit exceeds, you could take necessary actions

1
  • Thanks San Tosh. The limits have not yet been hit. Nov 29, 2016 at 9:42
0

Usually all org is given a 1000 emails/day. Also not more than 10 emails can be sent during a single transaction unless it is a batch class innvocation.

Please check the limits in following places.

  1. Limit provided for the sales force to your org and the remaining count also

  2. verify the debug logs to see how many mails have been sent already .normally it appears like "You have made 1 email calls out of 10 allowed".

As a workaround you can use batch class to overcome this limitation provided that your program logic can be implemented via batch interface.

2
  • Thanks blackwind. I have verified the limits. Also batch is not an option as it has to be real time. Nov 29, 2016 at 9:43
  • @SandeepChopra, the 50-60 mails which you said you were able to send wihtout any issues, can you let us know how this is being sent,what is the time gap between each mail (avg).
    – blackwind
    Nov 29, 2016 at 10:30
0

From https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm#email_limits_section:

"In Developer Edition orgs and orgs evaluating Salesforce during a trial period, you can send mass email to no more than 10 external email addresses per day. [...] Additionally, your org can send single emails to a maximum of 15 email addresses per day."

If you are developing in a Sandbox, the number of single emails you can send out is extremely restricted. It's usually not capped directly at 15 and you can sneak some more through, but not many. Try deploying and running the same test in your production org to see if the problem persists.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .