How to get form to email as an attachment to me & client

CIBBlou 26 Apr, 2009
I need assistance with my form - when the form is submitted the form will be a pdf attachment or file attachment on the email instead of in the email text. i am a beginner at this.
Can you please help me with this? & When is the new release of Chronoforms coming?
GreyHead 26 Apr, 2009
Hi cibblou,

I'm not sure how to get the results as an attachment. There have been a couple of threads about this in the past. I vaguely remember that the last poster managed to solve it but I'm not sure.

Next release is in a few days.

Bob
Max_admin 27 Apr, 2009
Hi cibblou,

"file attachment" of which type ?

as long as you can create a file on the server with the results and feed the attachments array with its path then you can attach it to the email!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CIBBlou 27 Apr, 2009
Max,
As per our emails last week, we discussed coding to make the form email as text file attachment & not in the email content. Which is easier - form to generate PDF or text file? What coding is needed to do this?
Max_admin 30 Apr, 2009
Hi cibblou,

try this:


jimport('joomla.utilities.error');
jimport('joomla.filesystem.file');
$MyForm =& CFChronoForm::getInstance('form_name_here');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);

if(!JFile::write(JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'uploads'.DS.$MyForm->formrow->name.DS.'data.txt', 'Some text')){
	JError::raiseWarning(100, 'Couldn\'t create upload directroy 2');
}else{
$MyUploads->attachments[] = JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'uploads'.DS.$MyForm->formrow->name.DS.'data.txt';
}


in the onSubmit code box!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
CIBBlou 05 May, 2009
hi Max,
I tried the code in the onsubmit code box - but when i received the email all the form questions & answers were still in the text of the email not as a attachment to the email.
Max_admin 06 May, 2009
did you get any attachments ? do you see the text "some text" in the email ? did you get any errors after the form is submitted assuming that you have no redirect URL ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
moriwenne 06 May, 2009
Greets Max, don't know where cibblou is but I tried it. I put the code in the box. When I hit submit the page shows the code i put in that box. The email received has only the file I uploaded and there is no data.txt.
I reckon what that piece of code is trying to do is to write a file data.txt and then attach it to the array to send out? Did it work for you when you wrote it?

Mori
deaddy64 07 May, 2009

did you get any attachments ? do you see the text "some text" in the email ? did you get any errors after the form is submitted assuming that you have no redirect URL ?

Max


I checked this code. It works. I recieve "some data.txt" with "some text" in it.
Max_admin 08 May, 2009
Thanks deaddy64 for confirming!

@Mori, make sure you added the form name in the correct place in the code and included the code between 2 PHP tags <?php ?> and added it in the onsubmit code box!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jupitergardens 10 May, 2009
I added this code to my On submit Before sending email, and it appears to have made no difference. I received my email. The file was listed in the email (and uploaded to my server), but it wasn't attached.

Here's the code I used:
<?php ?>
jimport('joomla.utilities.error');
jimport('joomla.filesystem.file');
$MyForm =& CFChronoForm::getInstance('JGsubmissionform');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);

if(!JFile::write(JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'uploads'.DS.$MyForm->formrow->name.DS.'data.txt', 'Some text')){
   JError::raiseWarning(100, 'Couldn\'t create upload directroy 2');
}else{
$MyUploads->attachments[] = JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'uploads'.DS.$MyForm->formrow->name.DS.'data.txt';
}
<?php ?>


Thanks!
deaddy64 10 May, 2009
jupitergardens
<?php ?> - it isn't right!
You must use construction:
<?php
*******
?>
And try to attach an existing file.
jupitergardens 12 May, 2009
I'm pretty new to coding. My file field is file_8. How would I attach an existing file?

Thanks!
Max_admin 12 May, 2009
Hi jupitergardens,

if your form has file field then you don't need any code to get the file attached to the email, you need to configure the uploads, please check the file upload tutorial from the tutorials page!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jupitergardens 12 May, 2009
Okay, because my uploads work just fine. Did I get confused? I thought this script would take the file and also attach it to an email.

Thanks!!!!!
deaddy64 12 May, 2009
:oops: I'm sorry but since now it's not work.๐Ÿ˜Ÿ I pasted this example again. The file created but not attached. $_FILES Array is empty. What can I do to make it work well? ๐Ÿคจ Must I switch on Upload in my form settings?
GreyHead 12 May, 2009
Hi deaddy64,

Must I switch on Upload in my form settings?


Yes and add the settings to control the uploads - please get the File Uploads tutorial from the Tutorials link above.

Bob
Max_admin 12 May, 2009

Okay, because my uploads work just fine. Did I get confused? I thought this script would take the file and also attach it to an email.

Thanks!!!!!


Hi jupitergardens,

Do you have a form which uploads the file and attach it to the email ? if so then all is fine for you, ignore this!๐Ÿ™‚

Hi deaddy64,

the $_FILES array should be empty, we are not uploading a file, we are creating a file on server and attaching it to the email, what are you trying to do exactly and I will tell you my thoughts ?

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
deaddy64 12 May, 2009
I'm creating an excel document (.xls file) with PHPExcel before sending mail and trying to attach it. It works for a short time when i was testing it. After that I changed somthing in my form. And now it doesn't work.
GreyHead 12 May, 2009
Hi deaddy64,

Test with an Excel file that you are sure is OK and in the correct folder. Turn on DeBug for your form and you should see the $attachments array at the end of the dummy email. DeBug until the attachment is good, then retest with PHPExcel to make sure that the two parts are working together.

Bob
Max_admin 14 May, 2009
Hi deaddy64,

have you tried Bob's suggestion ? you will need this code piece and you will need to add the file data.xsl at the path shown below:

$MyForm =& CFChronoForm::getInstance('JGsubmissionform');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);

$MyUploads->attachments[] = JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'uploads'.DS.$MyForm->formrow->name.DS.'data.xsl';

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
deaddy64 18 May, 2009
Hi all again. I solved my problem.lightbulb I checked settings in "Setup Email" -> "Enable attachments" it was "Yes". I reseted it (set "no", then "yes"). After these manipulations my form works well. Thank you all!
Max_admin 18 May, 2009
Thanks for posting about this, so all is working fine now ?๐Ÿ™‚

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
deaddy64 18 May, 2009
Yes, it's working fine. ๐Ÿ™‚ thnx
diva 09 Jun, 2009

Hi cibblou,

try this:


jimport('joomla.utilities.error');
jimport('joomla.filesystem.file');
$MyForm =& CFChronoForm::getInstance('form_name_here');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);

if(!JFile::write(JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'uploads'.DS.$MyForm->formrow->name.DS.'data.txt', 'Some text')){
	JError::raiseWarning(100, 'Couldn\'t create upload directroy 2');
}else{
$MyUploads->attachments[] = JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'uploads'.DS.$MyForm->formrow->name.DS.'data.txt';
}


in the onSubmit code box!

Regards
Max



Hi GH, Max...

Sorry to bring this thread back up.
Because this is almost exactly what I need! ^__^

But instead of txt file, i need the attachment to be in PDF. And in that PDF is my fields listed.
Can you guys help me with this one?
I can also live if the attachment is txt file.

How to change the example 'Some Text' with my fields?
Uh i'm so close... i think.
Been spending few days in the forum trying to find how to.

Thanks!
diva 09 Jun, 2009
Oh and I willing to pay for this code.
Should i post a thread on professional room?
GreyHead 09 Jun, 2009
Hi diva,

I've been looking for the last day to two at using PhocaPDF with ChronoForms - it looks as though it could be ideal for this. But it needs a custom plugin written and the documentation is zero - still I'm making some progress and have a request in to Jan for a little guidance.

Bob
diva 12 Jun, 2009
Goodie, good news!
I hope i can help you guys... but my knowledge in programming is next to... umm... 0.

Sow wish you the best luck in the world for one of the best com in Joomla.
This topic is locked and no more replies can be posted.