my email limit is exceeded after sending 10-12 emails..what could be the problem..as i have seen the limit is 1000 emails/day.i am not able to find out what could be the problem..Can some give me some suggestions. As i also know we can send 10 emails in a single transaction.I am sending emails in a batch class.
I am calling this batch class on button click and filling emailList with emailsId's.
String query='Select id from Lead';//No use of this query
Batch_send_emails bse=new Batch_send_emails();
bse.query=query;
bse.resendEmails=emailList;
database.executebatch(bse);
**Batch Class**
if(!resendEmails.isEmpty())
{
for(String s:resendEmails)
{
emailsLeads.add(s);
}
}
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);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
Best Answer
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
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
When you look at the log you should see
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).