Adding an attachment to the emailed form.

boost 07 Nov, 2009
OK - so I've search through the forum, and can't find my answer.....

Is there any way to add an attachment to the resulting email which comes from the form.
I've a situation where I need potential customers to register (using a Chrono Form), and then when the resulting email gets sent to A)me, and B)the customer too, giving them a copy of the submitted information. I would also like to add an attached PDF 'information sheet' to this email sent to my customer.

I Would of thought another option in the ToolBox under the Setup Emails tab would do it.

Thoughts anyone?
Cliff.
GreyHead 09 Nov, 2009
Hi Cliff,

You can do it with this code in the OnSubmit Before box
<?php
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments[] = 'path_to_file/file_name';
?>

Bob
boost 09 Nov, 2009
Fantastic.

Thanks for that Bob.
All works a treat.....

Being a complete PHP thicky!
One last question, what would be the syntax for adding more than one attachment?

Would it be :
<?php
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments[] = 'path/file' & 'path/file';
?>



One thing I will add here - (for other newbies/thickies :-) ) is that you don't need any leading / in the file path.
For instance if your file resides at http://www.mydomain.com/images/stories/myfile.pdf
you only need:
$MyUploads->attachments[] = 'images/stories/myfile.pdf'
on this line.
GreyHead 09 Nov, 2009
Hi Cliff,

Not quite so simple
<?php
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments[] = 'path_1/file_1';
$MyUploads->attachments[] = 'path_2/file_2';
?>
(Where path_1 & path_2 can be the same, or different).

Bob
boost 09 Nov, 2009
Excellent - Thanks Bob.

Cliff.
This topic is locked and no more replies can be posted.