I have written the following code. On execution, it is not throwing any error. But I am not getting any mail, or any log statements.
public class BatchApexBL implements Database.batchable<Sobject>,Database.Stateful{
public integer count = 0;
public Database.QueryLocator start(Database.BatchableContext bc){
String str ='select id,name from Meeting__c';
return Database.getQueryLocator (str);
}
public void execute(Database.BatchableContext bc, List<Meeting__c>laps){
Integer meetCount = laps.size();
Integer attnCount = 0;
for(Meeting__c lap :laps){
List<Attendee__C> attList=new List<Attendee__c>();
attList=[Select Id,Name,Attendee_Email__c,Country__c,Status__c,Attendee__c.Meeting__c from Attendee__c where Meeting__c=:lap.name];
attnCount = attnCount + attList.size();
}
String msg = 'Meeting count '+ string.valueof(meetCount)+' Attendee count ' + string.valueof(attnCount);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {'[email protected]'});
mail.setReplyTo('[email protected]');
mail.setSenderDisplayName('Batch Processing');
mail.setSubject('Batch Process Completed');
mail.setPlainTextBody(msg);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
public void finish(Database.BatchableContext bc){
system.debug(count);
}
}
Found this in the logs
39.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
09:19:04.0 (585748)|USER_INFO|[EXTERNAL]|0056F000006d5Em|[email protected]|Pacific Standard Time|GMT-08:00
09:19:04.0 (621914)|EXECUTION_STARTED
09:19:04.0 (628420)|CODE_UNIT_STARTED|[EXTERNAL]|01p6F000008JIhi|BatchApexBL
09:19:04.0 (2932738)|HEAP_ALLOCATE|[72]|Bytes:3
09:19:04.0 (2978342)|HEAP_ALLOCATE|[77]|Bytes:152
09:19:04.0 (2994481)|HEAP_ALLOCATE|[342]|Bytes:408
09:19:04.0 (3014939)|HEAP_ALLOCATE|[355]|Bytes:408
09:19:04.0 (3034099)|HEAP_ALLOCATE|[467]|Bytes:48
09:19:04.0 (3065061)|HEAP_ALLOCATE|[139]|Bytes:6
09:19:04.0 (9143546)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:78
09:19:04.0 (9306369)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:11
09:19:04.0 (9321291)|SYSTEM_METHOD_ENTRY|[15]|BatchableContextImpl.BatchableContextImpl()
09:19:04.0 (9325448)|STATEMENT_EXECUTE|[15]
09:19:04.0 (9335716)|SYSTEM_METHOD_EXIT|[15]|BatchableContextImpl
09:19:04.0 (9341610)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
09:19:04.0 (9345888)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
09:19:04.0 (9352875)|VARIABLE_SCOPE_BEGIN|[31]|this|Database.BatchableContextImpl|true|false
09:19:04.0 (9409439)|VARIABLE_ASSIGNMENT|[31]|this|{}|0x2b16200
09:19:04.0 (9415695)|VARIABLE_SCOPE_BEGIN|[31]|jobId|Id|false|false
09:19:04.0 (9526011)|VARIABLE_ASSIGNMENT|[31]|jobId|"7076F00006prWJ8QAM"
09:19:04.0 (9532894)|VARIABLE_SCOPE_BEGIN|[31]|childJobId|Id|false|false
09:19:04.0 (9541392)|VARIABLE_ASSIGNMENT|[31]|childJobId|null
09:19:04.0 (29055006)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:71
09:19:04.0 (29072438)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:7
09:19:04.0 (29084905)|METHOD_ENTRY|[1]|01p6F000008JIhi|BatchApexBL.BatchApexBL()
09:19:04.0 (29089787)|STATEMENT_EXECUTE|[1]
09:19:04.0 (29095835)|STATEMENT_EXECUTE|[1]
09:19:04.0 (29102946)|METHOD_EXIT|[1]|BatchApexBL
09:19:04.0 (29107060)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:20
09:19:04.0 (29109857)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
09:19:04.0 (29117467)|VARIABLE_SCOPE_BEGIN|[35]|this|BatchApexBL|true|false
09:19:04.0 (29184443)|VARIABLE_ASSIGNMENT|[35]|this|{"attnCount":16,"count":0,"meetCount":17,"msg":"Meeting count 17 Att (14 more) ..."}|0x70da6e50
09:19:04.0 (29194118)|VARIABLE_SCOPE_BEGIN|[35]|bc|Database.BatchableContext|true|false
09:19:04.0 (29307959)|VARIABLE_ASSIGNMENT|[35]|bc|{"jobId":"7076F00006prWJ8QAM"}|0x2b16200
09:19:04.0 (29316590)|STATEMENT_EXECUTE|[35]
09:19:04.0 (29318223)|STATEMENT_EXECUTE|[37]
09:19:04.0 (29385888)|VARIABLE_SCOPE_BEGIN|[37]|mail|Messaging.SingleEmailMessage|true|false
09:19:04.0 (29442628)|VARIABLE_ASSIGNMENT|[37]|mail|"common.api.soap.wsdl.SingleEmailMessage@56bb0c29"|0x5bdacc6
09:19:04.0 (29449982)|STATEMENT_EXECUTE|[38]
09:19:04.0 (29491406)|HEAP_ALLOCATE|[38]|Bytes:4
09:19:04.0 (29535017)|HEAP_ALLOCATE|[38]|Bytes:23
09:19:04.0 (29579384)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
09:19:04.0 (29599236)|STATEMENT_EXECUTE|[39]
09:19:04.0 (29603173)|HEAP_ALLOCATE|[39]|Bytes:22
09:19:04.0 (29649172)|STATEMENT_EXECUTE|[40]
09:19:04.0 (29653590)|HEAP_ALLOCATE|[40]|Bytes:16
09:19:04.0 (29675168)|STATEMENT_EXECUTE|[41]
09:19:04.0 (29678571)|HEAP_ALLOCATE|[41]|Bytes:23
09:19:04.0 (29697580)|STATEMENT_EXECUTE|[42]
09:19:04.0 (29795458)|STATEMENT_EXECUTE|[43]
09:19:04.0 (29833900)|HEAP_ALLOCATE|[43]|Bytes:4
09:19:04.0 (29913417)|HEAP_ALLOCATE|[50]|Bytes:5
09:19:04.0 (29929470)|HEAP_ALLOCATE|[56]|Bytes:5
09:19:04.0 (29937760)|HEAP_ALLOCATE|[64]|Bytes:7
09:19:04.0 (29976773)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
09:19:04.0 (30013655)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
09:19:04.0 (115463466)|EXCEPTION_THROWN|[43]|System.EmailException: SendEmail failed. First exception on row 0; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: []
09:19:04.0 (117604166)|HEAP_ALLOCATE|[43]|Bytes:114
09:19:04.0 (117703862)|FATAL_ERROR|System.EmailException: SendEmail failed. First exception on row 0; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: []
Class.BatchApexBL.finish: line 43, column 1
no access
?LimitException
.