Answers.Body: <p>We use the 'Title and Format' tab as Demerit mentions above and have stuck some text/html in the 'Report Header' box. To avoid attachments going out with them went with the below parameters for the scheduled job.
  instanceId=x
  format=print
  Not a global solution but may be suitable if results aren't too large.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-29T16:13:37.620Z
Answers.LastActivityDate: 2019-10-29T16:13:37.620Z
Answers.UserDisplayName: RebeccaTregenna
Answers.Body: <p>I'd probably just make a separate cron script that emails them the links and whatever text you want, i.e. not using the scheduled report task just a plain cron script. If you want to send to a civi group or something like that then the cron script could be a <code>cv</code> script and then use the civi api inside the script.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-25T22:36:41.237Z
Answers.Text: I need to stick to the civireport email functionality + scheduled job. I have a simple use case and just need to find the template to add text.
Answers.UserDisplayName: Andy Burns
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-25T23:09:21.780Z
Answers.Text: Ok, have added another answer.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-25T21:55:22.787Z
Answers.LastActivityDate: 2019-10-25T21:55:22.787Z
Answers.UserDisplayName: Demerit
Answers.Body: <p><strong>UPDATE:</strong>
  Since 5.29 you can do this in an extension do like the override example at <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar</a></p>
  <p>In the extension's main file example.php:</p>
  <pre><code>function example_civicrm_alterReportVar($varType, &amp;$var, $reportForm) {
    switch ($varType) {
      case 'outputhandlers':
        $var['\CRM_Report_OutputHandler_Pdf'] = '\My\Namespace\PdfOutputHandler';
        break;
    }
  }
  </code></pre>
  <p>and then in \My\Namespace\PdfOutputHandler something like:</p>
  <pre><code>namespace My\Namespace;
  use CRM_Example_ExtensionUtil as E;
  class PdfOutputHandler extends \CRM_Report_OutputHandler_Pdf {
  
    // Override to remove the attachment
    public function getFileName(): string {
      return '';
    }
  
    // This is similar to the default output but we replace the &quot;file is attached&quot; text. Adjust more as desired.
    // For reference the default is at https://github.com/civicrm/civicrm-core/blob/1f0a905a1a90e3bb68f0492022c488eab1ed3f82/CRM/Report/OutputHandler/Pdf.php#L52-L56
    public function getMailBody(): string {    
      $url = CRM_Utils_System::url('civicrm/report/instance/' . $this-&gt;getForm()-&gt;getID(), 'reset=1', TRUE);
      return $this-&gt;getForm()-&gt;getReportHeader() . '&lt;p&gt;' . ts('Report URL') .
        &quot;: {$url}&lt;/p&gt;&quot; . '&lt;p&gt;' .
        ts('Here is my text I want to add.') . '&lt;/p&gt;' .
        $this-&gt;getForm()-&gt;getReportFooter();
    }
  }
  </code></pre>
  <hr />
  <p><strong>OLDER ANSWER FOR OLDER VERSIONS:</strong></p>
  <p>The email body content starts here for csv: <a href="https://github.com/civicrm/civicrm-core/blob/5.18.4/CRM/Report/Form.php#L3413" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/5.18.4/CRM/Report/Form.php#L3413</a>, and a bit lower down for pdf.</p>
  <p>Note also the attachments are hardcoded in, a couple lines lower down.</p>
  <p>Note that in the report itself on the Title and Format tab you can add some text/html at the end of the header which will get included in the email.</p>
  <p>The code seems to be after hook_civicrm_alterReportVar so I don't think you can use that to remove the attachments, but you should be able to use hook_civicrm_alterMailParams to remove the attachments.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-25T23:09:07.030Z
Answers.LastActivityDate: 2023-07-23T14:27:19.890Z
Answers.LastEditDate: 2023-07-23T14:27:19.890Z
Answers.UserDisplayName: Demerit
Body: <p>I'd like to get users more in tune with their data by sending them notifications of certain high-value reports. I really don't want them with the data attached in a PDF or worse, a CSV. I'd rather just have the report link by itself (it already does this).</p>
  
  <p>How can I remove the attachment option altogether? </p>
  
  <p>Perhaps more importantly, how can I modify the email template so I can add some message content directly into the report email itself (not in the PDF attachment). What template is this using? I'd just want to hard-code some text that would apply to all reports.</p>
  
Tags: <reports><scheduled-job><system-workflow-messages>
Title: Modify emailed reports content
ThreadText: # Modify emailed reports content
  
  (Asked by: username_0 on 2019-10-25)
  
  I'd like to get users more in tune with their data by sending them notifications of certain high-value reports. I really don't want them with the data attached in a PDF or worse, a CSV. I'd rather just have the report link by itself (it already does this).
  
  How can I remove the attachment option altogether?
  
  Perhaps more importantly, how can I modify the email template so I can add some message content directly into the report email itself (not in the PDF attachment). What template is this using? I'd just want to hard-code some text that would apply to all reports.
  
  **Tags:** reports, scheduled-job, system-workflow-messages
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2019-10-25. Score: 3 | Accepted answer
  
  **UPDATE:**
  Since 5.29 you can do this in an extension do like the override example at <https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterReportVar>
  
  In the extension's main file example.php:
  
  ```
  function example_civicrm_alterReportVar($varType, &$var, $reportForm) {
    switch ($varType) {
      case 'outputhandlers':
        $var['\CRM_Report_OutputHandler_Pdf'] = '\My\Namespace\PdfOutputHandler';
        break;
    }
  }
  
  ```
  
  and then in \My\Namespace\PdfOutputHandler something like:
  
  ```
  namespace My\Namespace;
  use CRM_Example_ExtensionUtil as E;
  class PdfOutputHandler extends \CRM_Report_OutputHandler_Pdf {
  
    // Override to remove the attachment
    public function getFileName(): string {
      return '';
    }
  
    // This is similar to the default output but we replace the "file is attached" text. Adjust more as desired.
    // For reference the default is at https://github.com/civicrm/civicrm-core/blob/1f0a905a1a90e3bb68f0492022c488eab1ed3f82/CRM/Report/OutputHandler/Pdf.php#L52-L56
    public function getMailBody(): string {    
      $url = CRM_Utils_System::url('civicrm/report/instance/' . $this->getForm()->getID(), 'reset=1', TRUE);
      return $this->getForm()->getReportHeader() . '<p>' . ts('Report URL') .
        ": {$url}</p>" . '<p>' .
        ts('Here is my text I want to add.') . '</p>' .
        $this->getForm()->getReportFooter();
    }
  }
  
  ```
  
  ---
  
  **OLDER ANSWER FOR OLDER VERSIONS:**
  
  The email body content starts here for csv: <https://github.com/civicrm/civicrm-core/blob/5.18.4/CRM/Report/Form.php#L3413>, and a bit lower down for pdf.
  
  Note also the attachments are hardcoded in, a couple lines lower down.
  
  Note that in the report itself on the Title and Format tab you can add some text/html at the end of the header which will get included in the email.
  
  The code seems to be after hook\_civicrm\_alterReportVar so I don't think you can use that to remove the attachments, but you should be able to use hook\_civicrm\_alterMailParams to remove the attachments.
  
  
  ---
  
  ### Answer by username_1 on 2019-10-29. Score: 1
  
  We use the 'Title and Format' tab as username_2 mentions above and have stuck some text/html in the 'Report Header' box. To avoid attachments going out with them went with the below parameters for the scheduled job.
  instanceId=x
  format=print
  Not a global solution but may be suitable if results aren't too large.
  
  
  ---
  
  ### Answer by username_2 on 2019-10-25. Score: 1
  
  I'd probably just make a separate cron script that emails them the links and whatever text you want, i.e. not using the scheduled report task just a plain cron script. If you want to send to a civi group or something like that then the cron script could be a `cv` script and then use the civi api inside the script.
  
  > **Comments:**
  > **username_0**: I need to stick to the civireport email functionality + scheduled job. I have a simple use case and just need to find the template to add text.  
  > **username_2**: Ok, have added another answer.  
  
  ---
  
  