4
Integer email_left = Limits.getEmailInvocations();
system.Debug('Used Email: '+email_left);
Integer emailLimit = Limits.getLimitEmailInvocations();
system.Debug('Email Limit: '+emailLimit);

I got the following code but the email_left always ouput 0. Even there is no Gorvernor's Limit on email. And emailLimit always output 10.

I want to know how many email used, or any functions to know the remaining email. So that i can create a condition:

if(remaining != 0){
   //Send Email
}else{
   //Do Something
}

1 Answer 1

5

This is the per-transaction limit, not the global daily limit on sends. Limits.getEmailInvocations returns the number of calls (not total emails sent) in the current context, and Limits.getLimitEmailInvocations shows the maximum number of calls you can use (10) in the current transaction. The amount remaining is the difference between the two (limit-used).

See reserveMassEmailCapcity and the related reserveSingleEmailCapacity to tell if your transaction will fail if you attempt to send the specified number of messages.

You must log in to answer this question.

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