You need to sign in to do that
Don't have an account?

How to send a mail after completing the batch
This is my code
=============
global class BatchApex implements Database.Batchable<sobject>{
global Database.QueryLocator start(Database.BatchableContext bc){
return Database.getQueryLocator('select id from Opportunity');
}
global void execute(Database.BatchableContext bc,List<Opportunity>scope){
for(Opportunity o:scope){
o.Name='sandhya';
}
update scope;
}
global void finish(Database.BatchableContext bc){
Messaging.SingleEmailMessage[] mail=new Messaging.SingleEmailMessage();
String[] toAddresses=new String[] {'forcesfdcloud@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('sending mail ');
mail.setPlainTextBody('process completed success fully');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
I want to update my opportunities. After updating the opportunities i want to send a mail to the above mentioned address, but it shows error like" Illegal assignment from Messaging.SingleEmailMessage to List<Messaging.SingleEmailMessage>" can any one tell me how to solve this issue.
=============
global class BatchApex implements Database.Batchable<sobject>{
global Database.QueryLocator start(Database.BatchableContext bc){
return Database.getQueryLocator('select id from Opportunity');
}
global void execute(Database.BatchableContext bc,List<Opportunity>scope){
for(Opportunity o:scope){
o.Name='sandhya';
}
update scope;
}
global void finish(Database.BatchableContext bc){
Messaging.SingleEmailMessage[] mail=new Messaging.SingleEmailMessage();
String[] toAddresses=new String[] {'forcesfdcloud@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('sending mail ');
mail.setPlainTextBody('process completed success fully');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
I want to update my opportunities. After updating the opportunities i want to send a mail to the above mentioned address, but it shows error like" Illegal assignment from Messaging.SingleEmailMessage to List<Messaging.SingleEmailMessage>" can any one tell me how to solve this issue.
Please check below post for more information
1) http://amitsalesforce.blogspot.in/search/label/Email
Please update your code like below Let us know if this will help you