FAQs

How can I attach a file I have created to an email?

Written
This request came from a user whose form created a CSV file which needed to be emailed. The way to do it is to add an entry into the $form->files array that the Email action can then read in the same way as it can an uploaded file.
In a Custom Code action before the Email action add a code snippet like this:
<?php
$form->files['my_file'] = array(
  'name' => $my_file_name,
  'original_name' => '',
  'path' => $my_file_path.$my_file_name,
  'size' => '',
  'link' => str_replace(JPATH_SITE.DS, JURI::root(), $my_file_path.$my_file_name)
);
?>
 Change the highlighted parts to match the needs of your form and file.
Then you can use my_file (or whatever you changed that to) in the Email action Attachments box.