+ Start a Discussion
Kevin Chiles 930Kevin Chiles 930 

Email Trigger Firing twice


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
        //set target object for merge fields
        //set to save as activity or not
        //add address's that you are sending the email to
        String []ToAddress= new string[] {'ash@megapath.com' }; 

        //set addresses
            //add mail
Help me Obi Wan, you're my only hope

Nayana KNayana K
Kevin Chiles 930Kevin Chiles 930
So I would just throw that at the top of my code before I get it started?  Or do I need to nest it within the code?

Thank you for the quick response!!!