You need to sign in to do that
Don't have an account?
Nitin Palmure 5
Send mass email using before delete trigger
I am trying to write a trigger which will send an email to fixed number of folks (Let's say 3). I was able to write a trigger for single user. However, I find it tricky to get it for three users. and would like to have some help.
Following is my code:
Please help me as there are three specific users lets take an example of three contacts with email Id as abc@123.com, def@123.com and ghi@123.com.
Thank you
Following is my code:
trigger triggerAlertonDeleteMarketplaceRule on Marketplace_Rule__c (before delete) { Messaging.reserveSingleEmailCapacity(trigger.size); List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>(); Set<Id> accountIds = new Set<Id>(); EmailTemplate Et = [SELECT Id from EmailTemplate where Name =: 'Marketplace Rule Deleted']; for(Marketplace_Rule__c acc : Trigger.old){ if(acc.Related_Account__c != null){ accountIds.add(acc.Related_Account__c); } } Map<Id, Account> accounts = new Map<Id, Account>([SELECT Id, Name FROM Account WHERE Id in :accountIds]); Contact tempContact = [SELECT Id FROM Contact WHERE email =: 'nitin.palmure@abc.com']; for(Marketplace_Rule__c mpr : Trigger.old){ Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setTargetObjectId(tempContact.Id); email.setWhatId(mpr.id); email.setSaveAsActivity(false); email.setTemplateId(Et.Id); emails.add(email); } Messaging.sendEmail(emails); }
Please help me as there are three specific users lets take an example of three contacts with email Id as abc@123.com, def@123.com and ghi@123.com.
Thank you
Please add two more fields in email definition:
Hope this helps!!!
Thanks,
Gaurav
Skype: Gaurav62990