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
Nihar Annamaneni 7Nihar Annamaneni 7 

batch class for two users to send mails regarding there opportunitys closed date is tommorow

Hi all,
I have a batch class for two users to send mails regarding there opportunitys closed date is tommorow
but my batch class i sending to only one user 
how can i send to another user mail
can anyone help me

my code :
global class sendemail implements Database.Batchable < sobject > {
global Database.QueryLocator start(Database.BatchableContext bc) {
       String Query;
       Date dt = date.today().addDays(1);
       Query = 'SELECT Name,Id From Opportunity WHERE CloseDate =: dt ';
       return Database.getquerylocator(Query);
       }

global void execute(Database.BatchableContext bc, List < Opportunity > opplist) {
       List < Messaging.SingleEmailMessage > emails = new List < Messaging.SingleEmailMessage > ();
       for (Opportunity opp: opplist) {
       // opp.CloseDate = 'createddate+1'; 
       Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
       email.setToAddresses(new String[] {'nihar.annamaneni@gmail.com'});
       email.setSubject('opportunity closed date'); 
       String body='';
       body += '<html></br> </br>' + 'Dear user, Your opportunity ' + '<a href="'+URL.getSalesforceBaseUrl().toExternalForm() + '/' + opp.name + '">' + opp.name + '</a>' + ' closed date is tommorow';
       body +=  '</body></html>';
       email.setHtmlBody(body);
       emails.add(email);
       }
       Messaging.sendEmail(emails);
       // update opplist;
       }

global void finish(database.BatchableContext bc) {}
}

thanks inadvance..........
v varaprasadv varaprasad
Hi Nihar,

Check below code once : 

 
list<string> toddresses = new list<string>();
toddresses.add('nihar.annamaneni@gmail.com');
toddresses.add('another emailid');

email.setToAddresses(toddresses);

Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com