You need to sign in to do that
Don't have an account?
Email Notification from apex
Hi
I have written the below trigger on case, If i edit or create a new with a given condition im getting a two mail alert. Please help me on this.
trigger EmailNotificationForQuote on Case (after insert, after update, before insert,before update) {
for(Case newCase: Trigger.new){
System.debug(Trigger.new.size()+'------test--');
System.debug(newCase+'------testing--');
if(newCase.Status=='Open'){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'test@gmail.com'};
mail.setToAddresses(toAddresses);
string subject='Hi';
string body='Hw ttttttttttttttttttttttttttttt u';
mail.setSubject(subject);
mail.setPlainTextBody('Hhhhhhhhhhhhhhhhh');
mail.setHtmlBody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
Thanks
Hi,
Your trigger fire conditions are "after insert, after update, before insert,before update".
So the trigger is actually fired twice (before and after) :)
Regards,
Hengky
One notification from Before Insert the other one comes from After Insert...Just use the right case...