Skip to main content
I'm using the following to email my report as CSV but it just includes the first 2000 rowes in the csv file while my report has more than 50000 rowes. how can I solve this? thanks in advance:

global class Report implements System.Schedulable {

    global void execute(SchedulableContext sc) {

        ApexPages.PageReference report = new ApexPages.PageReference('/00O60000003XpO6?csv=1');

        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();

        attachment.setFileName('testcsv');

        attachment.setBody(report.getContent());

        attachment.setContentType('text/csv');

        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();

        message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );

        message.setSubject('test');

        message.setPlainTextBody('test is attached.');

        message.setToAddresses( new String[] { 'test@test.com' } );

        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );

        

    }

}
3 Antworten
  1. 27. Apr. 2015, 13:55
    Bob, it's a multi object report for a custom object and activities, so I can't use dataloader or Jitterbit to export it, that's why I'm looking for a way to export this report as csv file and email it or put it on FTP on a Scheduled basis. but the apex just send the first 2000 rows as attachment to the email adress. 
0/9000