You need to sign in to do that
Don't have an account?
Kevin Chiles 930
Email Trigger Firing twice
Hello!
I have an Email trigger that seems to be firing twice. I cannot for the life of me figure out why. Basically the trigger is picking up a template and a the attachments associated to a custom objects record and emailing it to a team. This for some reason is firing 2 emails instead of one. Its driving me mad!
Chiles
I have an Email trigger that seems to be firing twice. I cannot for the life of me figure out why. Basically the trigger is picking up a template and a the attachments associated to a custom objects record and emailing it to a team. This for some reason is firing 2 emails instead of one. Its driving me mad!
trigger Send_TechDocs_Cloud on Sales_Handoff_Activity__c (after update) { for(Sales_Handoff_Activity__c SHA : trigger.new){ if (SHA.TAD_Status__c == 'TAD Complete' && SHA.Cloud__c==True && Trigger.oldMap.get(Sha.Id).TAD_Status__c != Trigger.newMap.get( Sha.Id ).TAD_Status__c ) { // && SHA.TAD_Status__c!=Trigger.oldMap.get(sha.id).TAD_Status__c //Retrieve Email template EmailTemplate et=[Select id from EmailTemplate where name=:'Cloud Tad Complete']; //Create email list List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>(); //Create attachment list List<Messaging.EmailFileAttachment> efalist = new List<Messaging.EmailFileAttachment>(); contact c =[select id, email from Contact where Email=:'kevin.chiles@megapath.com' limit 1]; //Create message Messaging.SingleEmailMessage singlemail = new Messaging.SingleEmailMessage(); //add template singleMail.setTemplateId(et.Id); //set target object for merge fields singleMail.setTargetObjectId(c.Id); singlemail.setwhatId(SHA.Id); //set to save as activity or not singleMail.setSaveAsActivity(false); //add address's that you are sending the email to String []ToAddress= new string[] {'ash@megapath.com' }; //set addresses singlemail.setToAddresses(toAddress); //add mail emails.add(singleMail); {Help me Obi Wan, you're my only hope
Chiles
Thank you for the quick response!!!
Kevin