single email limit exceeded salesforce very frequently..?
There is a limit on the number of emails you can send from Apex, this is 5,000 per 24 hours and you would need to raise a case and engage with Salesforce to get this raised.
I think that the error message you are seeing there refers to a different limit, which is that you can only call sendEmail 10 times within the same context. Is it possible that your apex code is calling that in a loop?
You should do something like this
List<Messaging.SingleEmailMessage> allMails = new List<Messaging.SingleEmailMessage>();
//now do your loop
.... {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(emailsLeads);
// mail.setCcAddresses(ccAddresses);
String subject='GoToMeeting Invitation Details for '+subject;
String body='test';
mail.setHtmlBody(body);
mail.setSubject(subject);
allMails.add(mail);
....
}
//Finished your loop? Now you have an array of mails to send.
//This uses 1 of your 10 calls to sendEmail that you are allowed
Messaging.sendEmail(allMails);
sendEmail can be called on an array of messages, so rather than call it once you should build up an array of singleemailmessage and then send them all in one call.
Edit A couple more things you can try to understand what the problem is
Before you make the sendEmail call, add
System.debug('You have made ' + Limits.getEmailInvocations() + ' email calls out of ' + Limits.getLimitEmailInvocations() + ' allowed');
When you look at the log you should see
You have made 1 email calls out of 10 allowed
If you see a series of messages (1,2,3 etc.) then you are calling it in a loop.
You can also check that there is capacity out of the 5,000 daily allowance still available (only if you are on a Winter '14 instance).
try {
Messaging.reserveSingleEmailCapacity(emailsLeads.size());
} catch (Exception e) {
// From Winter '14, this code is now executed.
System.debug('You have used up your daily allowance of mails');
}
Update - From Winter'17, limits have been raised to 5,000 instead of 1,000.
Single Messaging has limits as you cannot call sendEmail
method more than 10 times in single transaction and 1000 e-mail per license per day. Some how you are hitting these limits.
If you are sending email to organization internal users in that case you should use setTargetObjectId(userId)
instead of toAddress
. Pass user Id in that method.
setTargetObjectId(userId)
doesn't count against Salesforce governor limits.
I can confirm Salesforce changed the daily limit for Developer Edition orgs to 10 a few releases ago, this is indeed a significant drop from the before 1000. It caused issues with our development and testing teams. Eventually we made a case to get it raised back up to 1000 for some of our DE orgs, suggest you contact support and request the same, at least for your test orgs. It might also be worth raising an Idea to ask Salesforce to review this decision.
In Developer Edition organizations and organizations evaluating Salesforce during a trial period, your organization can send mass email to no more than 10 external email addresses per day. This lower limit does not apply if your organization was created before the Winter '12 release and already had mass email enabled with a higher limit. Additionally, your organization can send single emails to a maximum of 15 email addresses per day.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm