You need to sign in to do that
Don't have an account?
Michelle Soto
How can I send an email with a salesforce report attached?
I'm try to scheduler email send with a repor attached, but when i received the email, appear the next error in the file:
Could you tell me if there is another option to solve the need to send the attached file by mail?
global class Exporter implements System.Schedulable { global void execute(SchedulableContext sc) { DoExport(); } @future(callout=true) public static void DoExport() { ApexPages.PageReference report = new ApexPages.PageReference('/00O6g000004Z0nNEAS?csv=1'); Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment(); attachment.setFileName('report.csv'); attachment.setBody(Blob.valueof(report.getContent().toString())); attachment.setContentType('text/csv'); Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage(); message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } ); message.setPlainTextBody('The report is attached.'); message.setToAddresses( new String[] { 'user@example.com' } ); Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } ); } }Could you help me with this error please?
Could you tell me if there is another option to solve the need to send the attached file by mail?
Does the approach suggested in https://salesforcescool.blogspot.com/2021/06/send-salesforce-report-as-attachment.html work for you?
Also see similar scenario: https://salesforce.stackexchange.com/questions/283865/convert-report-data-to-csv-format-and-send-attachment-in-mail-using-apex
Thanks
All Answers
Does the approach suggested in https://salesforcescool.blogspot.com/2021/06/send-salesforce-report-as-attachment.html work for you?
Also see similar scenario: https://salesforce.stackexchange.com/questions/283865/convert-report-data-to-csv-format-and-send-attachment-in-mail-using-apex
Thanks
Below url will help to solve your problem:-
https://salesforcecodex.com/salesforce/sending-report-as-attachment-in-salesforce/
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh