Skip to main content
Instead of receiving an email notification for each new lead, our sales team would like to get a daily summary of their new, open leads emailed to each rep then a territory summary for each regional manager. I am currently using reports with a scheduled run for this but this does not seem scalable as we have limited scheduled report slots.

 

Is there another way to do this? Email alerts only allow me to pull data from one lead record vs a group of records unless I am missing something. 
2 respostas
  1. 31 de jul. de 2018, 10:00
    Hi Jay,

     

    Other option is custom coding. You just need to give the report Id and it will extract the report in Excel/CSV and then you can send the report in attachment using a schedular in email.

     

    Below is the code for help to achieve this.

     

    ApexPages.PageReference objPage = new ApexPages.PageReference('/{!ReportId}?excel=1'); Messaging.EmailFileAttachment objMsgEmailAttach = new Messaging.EmailFileAttachment(); objMsgEmailAttach.setFileName('Testing.xls');

     

    objMsgEmailAttach.setBody(objPage.getContent());

     

    objMsgEmailAttach.setContentType('application/vnd.ms-excel');

     

    If you want to extract report in CSV just replace excel with csv.

     

    Hope this will help !
0/9000