+ Start a Discussion
srikanth admin 24srikanth admin 24 

Messaging.sendEmail error..

Hi all 
Please help me in this program
 
trigger tgname on Account_Convace__c ( after update)
 {
 
         if(Trigger.IsAfter){
                        if(Trigger.IsUpdate){
 
         // Map <id,Account_Convace__c> anjimap = new Map <id,Account_Convace__c>();
          
        List<Messaging.SingleEmailMessage> mails =    new List<Messaging.SingleEmailMessage>();
                   for(Account_Convace__c abc:Trigger.new)
          {
          if( abc.Account__c != Trigger.oldmap.get(abc.ID).Account__c)
             mails.add(abc.email__c); 
             
         
          //for(Account_Convace__c  abcd : [select id, Email__c from  Account_Convace__c  where id in :UPdatedlist])
          
          Messaging.singleEmailmessage mail = new messaging.singleEmailmessage();
          mail.setToaddress(mails);
          mail.setsubject('Account name hsa been changed.');
          mail.setbody('dfdsfdkjsfdsfds');
         
         
         
          }
          messaging.sendEmail( mails);
          
 
 }
 }
 }


Thanks and regards,

Srikanth Annam..
 

suresh dupadasuresh dupada
Problem is that setToaddress, need to add emails in a list of string set that list to setToaddress



trigger tgname on Account_Convace__c ( after update)
 {
 
         if(Trigger.IsAfter){
                        if(Trigger.IsUpdate){
 
       
         list<String> ToAddressList=new  list<String>();
        List<Messaging.SingleEmailMessage> mails =    new List<Messaging.SingleEmailMessage>();
                   for(Account_Convace__c abc:Trigger.new)
          {
          if( abc.Account__c != Trigger.oldmap.get(abc.ID).Account__c)
             ToAddressList.add(abc.email__c); 
             
         
          //for(Account_Convace__c  abcd : [select id, Email__c from  Account_Convace__c  where id in :UPdatedlist])
          
          Messaging.singleEmailmessage mail = new messaging.singleEmailmessage();
          mail.setToaddress(mails);
          mail.setsubject('Account name hsa been changed.');
          mail.setbody('dfdsfdkjsfdsfds');
          mails .add(mail);
         
         
         
          }
          messaging.sendEmail( mails);
          
 
 }
 }
 }