• Prabu Thangavel
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
List <Messaging.SingleEmailMessage> mails =  new List <Messaging.SingleEmailMessage>();
        List <String> sendTo = new List <String>();        
        Id settargetid=queryApplication[0].Contact__c;
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        Messaging.SendEmailResult[] results;
        sendTo.add(toMail);
        mail.setToAddresses(sendTo);    
        mail.setSubject(mailSubject);
        mail.setHtmlBody(mailbody);
       // mail.setTemplateId(param1)
        system.debug('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'+emailTemplates[0].id + '>>>>>>>>>>>>>>>>>>'+emailTemplate);
       
        if(emailTemplates.size()>0)
        {
             mail.setTemplateId(emailTemplates[0].id);
        }
        if(queryApplication.size()>0){       
       // mail.setTargetObjectId(settargetid);
        mail.setTargetObjectId(c.id);
        mail.setTreatTargetObjectAsRecipient(true);
        }
        //system.debug('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'+queryApplication[0].Contact__c);
        //mail.setTreatTargetObjectAsRecipient(false);
        mail.setWhatId(recordId);
        mails.add(mail);