Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class deleteCampaignMembers implements Database.Batchable<sObject>
- {
- global String Query;
- global void deleteCampaignMembers()
- {
- Query='select id from campaignMember where createdDate > LAST_90_DAYS';
- }
- global Database.QueryLocator start(Database.BatchableContext BC)
- {
- return Database.getQueryLocator(query);
- }
- global void execute(Database.BatchableContext BC,List<sObject> scope)
- {
- Delete scope;
- }
- global void finish(Database.BatchableContext BC)
- {
- //Send an email to the User after your batch completes
- Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
- String[] toAddresses = new String[] {'dllewellyn@foodperspectives.com'};
- mail.setToAddresses(toAddresses);
- mail.setSubject('Apex Batch Job is done');
- mail.setPlainTextBody('The batch Apex job processed ');
- Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement