Just in case if somebody is looking for the same - here is my solution (based on info from other posts) - may need fine tuning & don't forget to filter your $formValues so it is just one-dimensional array otherwise you will end up with values like 'Array' (as a result of array to string conversion)
CreateCsvAttachment snippet:
$formit =& $hook->formit;
$formValues = $hook->getValues();
foreach ($formValues as $key => $value) {
$formFields[] = $key;
$formFieldsValues[] = $value;
}
$attachment_path = 'assets/components/form_csvs/';
// create csv name from form field 'name' stripped from blank spaces and
// all the strange chars; timestamp added at the end of file name
$csv_name1 = str_replace(' ', '_', $formValues['name']);
$csv_name2 = str_replace('/[^A-Za-z]+/', '_', $csv_name1) . '_' . time();
$fp = fopen($attachment_path . $csv_name2 . '.csv', 'a');
fputcsv($fp, $formFields);
fputcsv($fp, $formFieldsValues);
fclose($fp);
$hook->modx->getService('mail', 'mail.modPHPMailer');
$hook->modx->mail->mailer->AddAttachment($attachment_path . $csv_name2 . '.csv');
return true;
and then in FormIt call is hook added before email hook
[[!FormIt? &hooks=`CreateCsvAttachment,email,...` ...]
where '...' means other attributes or values
hope it helps somebody
[ed. note: krajicek last edited this post 9 years, 11 months ago.]