function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mangesh Honale 1Mangesh Honale 1 

Is EmailMessage object query call not supported in batch apex?

I am working with EmailMessage object. I have a batch apex and in execute method I need to query EmailMessage records. But query does not return any records. When I put the same query in a normal class (not batch apex class) it gives results. Here is execute method implementation:

public void execute(Database.BatchableContext BC, List < string > reportRowsList){
//some code
List<EmailMessage> eMsgList = [Select Id, ToAddress from EmailMessage];
system.debug('Size: ' + eMsgList.size());
//some code again
}

What is going wrong?