0

I am using Vf template for email alert and i am triggering this by a email service in a trigger. But whenever i am receiving email i am not getting any value populated. Can anyone let me know where i am going wrong -

Apex Class:-

public class send_NewTasks{   
  //capture the user id
    public ID salesRepID {get; set;}
    public List<Task__c> totalTasks ;

    public List<Task__c> gettotalTasks () {
        totalTasks= [select Name from Task__c where Status__c = 'Open' AND Project_Status_Approved__c =True AND Project__c = :salesRepID];
        return totalTasks;
    }
}

Component:-

<apex:component controller="send_NewTasks" access="global">
        <apex:attribute name="ToID" type="ID" description="New Tasks Assignment" assignTo="{!salesRepID}"/>
         <apex:outputText value="{!salesRepID}"></apex:outputText>
         {!totalTasks }
            <apex:datatable value="{!totalTasks }" var="item" border="1">
                        <apex:column headervalue=" Name ">
                            <apex:outputText value="{!item.name}"/>
                        </apex:column>

           </apex:datatable>
    </apex:component>

Trigger :-

trigger EmailService on Task__c (before update) {

EmailTemplate et=[Select id from EmailTemplate where name='Multiple Tasks'];

List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();

    for(Task__c t : Trigger.new)
    {

       If(t.Project_Status_Approved__c &&t.Status__c == 'Open' ){
       String userEmail = t.Task_Executioner1__c;
       String[] toAddresses = new String[] {userEmail};    
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          system.debug('11111');
          mail.setToAddresses(toAddresses);
          mail.setSenderDisplayName('Test');
          mail.setTargetObjectId('0031100000dtg5C');
          mail.setTemplateId(et.Id);
          mails.add(mail);

       }
    }
    system.debug('2222222');
 Messaging.sendEmail(mails);
}

Regards

sfdc_to_learn
  • 1,732
  • 2
  • 32
  • 89

0 Answers0