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
sandeep reddy 37sandeep reddy 37 

batch apex using email processing

I have batch apex class 
depending upon execute method all records assocated with email we can sent emails to this emails so my batch apex class is

global  class batchwithemails implements database.Batchable<sobject> 
{
    global list<string> toaddress=new list<string>();
    global database.Querylocator start(database.batchablecontext bc){
        string s='select id,name,industry,srinivasreddy__email__c from account limit 20';
        return database.getQueryLocator(s);
        
    }
    global void execute (database.BatchableContext bc,list<account> scope){
        for(account a:scope){
            a.srinivasreddy__Active__c='yes'; 
            toaddress.add(a.srinivasreddy__email__c);
            
        }
        update scope;
        
}
    global void finish (database.BatchableContext bc){
        messaging.reserveSingleEmailCapacity(20);
        messaging.SingleEmailMessage m=new messaging.SingleEmailMessage();
        string[] toaddres=new string[]{'toaddress'};
            m.setToAddresses(toaddress);
        m.setPlainTextBody('nothing to display');
        m.setSubject('first');
        Messaging.sendemail(new messaging.SingleEmailMessage[]{m});
    }

please help me