You need to sign in to do that
Don't have an account?
Batch class for sending an email notification to public group user
Dear Developers,
I would like to send notification of public group users by using batch class(weekly based). can anyone please advise me how can i change my code for accurate requirement.
Batch Class
Hearty Thanks In Advance !!
Regards,
Soundar P
I would like to send notification of public group users by using batch class(weekly based). can anyone please advise me how can i change my code for accurate requirement.
Batch Class
global class PSO_etmfErrorLogBatch implements database.batchable<SObject>{ global database.querylocator start(database.batchableContext bc){ system.debug('Start Method Running'); return Database.getQueryLocator('Select Id,name from eTMF_Files_Error_Log__c'); } global void execute(database.batchableContext bc, List<eTMF_Files_Error_Log__c> errlogList){ system.debug('Execute Method Running'); List<String> toAddresses = new List<String>(); List<User> userList = [select id, name, email, isactive, profile.name, userrole.name, usertype from user where id in (select userorgroupid from groupmember where group.name = 'Document Tracking Admin')]; for(User u : userList){ toAddresses.add(u.email); } List < Messaging.SingleEmailMessage > emails = new List < Messaging.SingleEmailMessage > (); for (eTMF_Files_Error_Log__c irow_erLog : errlogList) { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(toAddresses}); email.setSubject('Last Week ETMF Error Log'); email.setPlainTextBody('Dear user, Please Check Last Week ETMF Error Log'); emails.add(email); } Messaging.sendEmail(emails); } global void finish(database.batchableContext bc){} }
Hearty Thanks In Advance !!
Regards,
Soundar P
All Answers
I have updated you code and try this. Let me know if it help you. Thanks
Niraj
Thanks for your valuable responses.
Regards,
Soundar Rajan P.