function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jane LiuJane Liu 

scheduled report stopped sending report as .csv all of sudden, changed to _csv.html instead, no code/config change

We have a scheduled report from the following apex class, it has been sending .csv files everyday until Nov 29 that it suddenly changed to _csv.html. I can't figure out why the change. Any idea?

global class ReportExporter implements System.Schedulable {
global void execute(SchedulableContext sc) {
DoExport();
}

@future(callout=true)
public static void DoExport() {
ApexPages.PageReference report = new ApexPages.PageReference('/00OC0000006zAnv?csv=1&enc=UTF-8');
Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
attachment.setFileName('All_PROB_AMOUNT.csv');
if(Test.isRunningTest()) {
attachment.setBody(blob.valueOf('Unit.Test'));
} else {
attachment.setBody(Blob.valueof(report.getContent().toString()));
}
attachment.setContentType('text/csv');
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
message.setSubject('Daily ALL PROB AMOUNT Report');
message.setPlainTextBody('The report is attached.');
message.setToAddresses( new String[] { 'test@test.com', 'test2@test.com' } );
Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );
}
}
Raj VakatiRaj Vakati
Are you sending attahcmenet from the report ? can u check is there any chanhes made to report 
Jane LiuJane Liu
The attachment is from the report, no change to the report. Report runs fine. The report need to be attached directly in the email as .csv. That’s why I created the apex class to send report result out instead of scheduling the report directly from report. All these worked before Nov 29. Jane
Raj VakatiRaj Vakati
Can u check what is there in _csv.html ??? 
Jane LiuJane Liu
[cid:image001.png@01D48B18.D069D620]
Jane LiuJane Liu
The attachment has the following content, if I click it, it downloaded the .csv file.
Before it's attached as .csv, not html.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="Refresh" content="0; URL=https://c.na8.content.force.com/servlet/servlet.EmailAttachmentDownload?q=pj5jeYgvuTMUueO%2BV37YTijMPPdOgtJp%2FtSDV2Z%2FpCM%2FY%2Bp4%2BAGQVt9pord864bq2p4gRAKI4saX7Xd1lOBV2g%3D%3D"></head><body><div>Attachment not opening? Click this link: <a href="https://c.na8.content.force.com/servlet/servlet.EmailAttachmentDownload?q=pj5jeYgvuTMUueO%2BV37YTijMPPdOgtJp%2FtSDV2Z%2FpCM%2FY%2Bp4%2BAGQVt9pord864bq2p4gRAKI4saX7Xd1lOBV2g%3D%3D">All_PROB_AMOUNT.csv</a></div></html>
Jane LiuJane Liu
Seems related with file size. If I add more filters to it to reduce the file size, it sents .csv instead of html automatically. Anybody aware of this?
user_user007user_user007
Did you solve this issue? I am facing a similar problem.
Jane LiuJane Liu
Surya, I can’t remember exactly what’s been done. But maybe reschedule it see if it helps? Good luck! Jane
user_user007user_user007
Thanks Jane, I rescheduled it and got the exact same message. I founf another thread where it had the same question it said it may be due the report is generated in classic and the user scheduled as a Lightning user and that may cause but i am not sure. Do you what is the same accepted file size?
 
user_user007user_user007
What is the accepted file size? *