I get an compile error when as Invalid Type: Trigger.new error for Line 3 for the following class;
public class NotifyOppyOwnerOnCaseTriggerHandler{
//Find closed cases and collect EmailIds on Oppty's
public List<String> findClosedCases(Trigger.new, String TempName ){
EmailTemplate et = [SELECT Id FROM EmailTemplate WHERE Name =:TempName];
List<string> toAddress = new List<string>();
Map<id,Case> case_map = new Map<id,Case>([Select Id, status,
Opportunity__r.Owner.email,
Opportunity__r.Id, Opportunity__r.IsClosed
From Case Where Status = 'Closed Won' OR Status = 'Closed Lost']);
//Find out how many new cases got closed and collect emailids
for(case c: trigger.new){
if(case_map.containsKey(c.id)){
if(case_map.get(c.id).status == 'Closed Won' || case_map.get(c.id).status == 'Closed Lost'){
//send email to the oppty owner by extracting oppty owner using case_map.get(c.id).Opportunity__r.Owner.email
//store the email ids of the recipients
toAddress.add(case_map.get(c.id).Opportunity__r.Owner.email);
}
}
}
return toAddress;
}
sendNotification(List<string> toAddress){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(et.Id);
mail.setToAddresses(toAddress);
mail.setSubject(et.Subject);
List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
allmsg.add(mail);
//Catch exceptions while sending email to recipients
try {
Messaging.sendEmail(allmsg,false);
return;
} catch (Exception e) {
System.debug(e.getMessage());
}
}
}