Forums

Attach File in Auto Response Email

vmethod 19 Jan, 2010
I have 2 questions:

1. What I need is when someone fills out my form, in the response email the visitor receives, a file is also attached.

Ok, so I have searched your forums and have found what I am looking for. The problem is I don't know where to put the snippet of code!

This is the code that I have found, I don't know which file to place it in (chronoform.php?) and where exactly. I don't know where "Add this code to the OnSubmit Before box" is:
<?php
if ( !$mainframe->isSite() ) return;
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments[] = 'images/newsletter.pdf';
?>


Is this how it is supposed to be?
/* Do Onsubmit before_email plugins*/
		if(!$MyForm->haltFunction["plugins_before_email"]){			
			$MyPlugins->runPlugin('before_email');		
			$MyForm->addDebugMsg('Form passed the plugins step (if enabled) OK');
			//show errors if any
			if($MyForm->showFormErrors($MyForm->formrow->name)){
				$MyForm->showForm($MyForm->formrow->name, $posted);
				return;
			}
                 if ( !$mainframe->isSite() ) return;
                      $form_id = $MyForm->formrow->id;
                      $MyUploads =& CFUploads::getInstance($form_id);
                      $MyUploads->attachments[] = 'images/newsletter.pdf';	
		}


2. I need to have two contact forms with two different files to attach and email. For example, when a visitor files out Form A, they receive File A in the email response. If they fill out Form B, they receive File B.

Is this possible?

Please help! I'm running out of time LOL...

THANK YOU!!!
nml375 19 Jan, 2010
Hi,
Lets start with #1, shall we?
The code should indeed go into the "On Submit - Before Email" box, which you'll find in the Form Editor (not Wizard Edit) under the Form Code tab. Simply click on the name of the form in the Form Manager in the backend, and you'll open the form in the Form Editor.
There is no need to edit any of ChronoForm's files for this!

Next, #2:
Yes, simply adjust the code to point to the new file, and enter it in the "On Submit - Before Email" box of the second form. These settings are unique for each form.

/Fredrik
vmethod 19 Jan, 2010
O M G.

I love you! Thank you thank you!
This topic is locked and no more replies can be posted.