Forums

Can ChronoForms Create an Email Form w/Attachments

Thumdar 24 Nov, 2007
I am trying to find a solution for a clients website and am wondering if ChronoForms can accomplish it. What I need is for a website visitor to be able to use the form as a means to select and email PDF documents through the website to the email addresses of his business associates. It's basicly creating an email and adding multiple attachments and then sending them through the website.

Here's a mock up of the basic form layout idea:


Does ChronForms have this ability?

Thanks in advance.
GreyHead 24 Nov, 2007
Hi thumdar,

Can ChronoForms do this 'out of the box' - no, it can't. Can you use ChronoForms to create a form like this, yes certainly you can. But you'll need to create some custom php to make the form do what you want. There's a thread here on selecting emails from a drop-down that will give you part of what you want. Handling the pdfs requires a little more code to create an array of attachment files.

Bob
Thumdar 25 Nov, 2007

Hi thumdar,

Can ChronoForms do this 'out of the box' - no, it can't. Can you use ChronoForms to create a form like this, yes certainly you can. But you'll need to create some custom php to make the form do what you want. There's a thread here on selecting emails from a drop-down that will give you part of what you want. Handling the pdfs requires a little more code to create an array of attachment files.

Bob



Hey GreyHead, thanks for the quick response🙂

I had a feeling this was going to be rather complex. Unfortunately I"m far from a php script composer. Any chance you might have an idea of some component, module or mambot that could help in this situation?

Thanks again!
GreyHead 25 Nov, 2007
Hi thumdar,

I don't know anything better that ChronoForms for doing this (maybe one of the other form extensions but I don't think so).

Provided you aren't in a great rush I'll try to sketch something out next week for you to try.

Bob
Thumdar 25 Nov, 2007

Hi thumdar,

Provided you aren't in a great rush I'll try to sketch something out next week for you to try.

Bob



Wow, really? That would be fantastic, thank you.

You had said that there is a thread discussing how to select email addresses from a drop down menu, but that isn't going to work. It really needs to be an empty field that can be filled out with the email address needed. It's basically like an online email client that registered users have access to and where they can select pdf's from a designated folder. Truth is ~ I think it would be an excellent extension for other Joomla users.

Imagine a component that was an email client with an address book built in. When registered users wanted to send an email they could do it through the website and add attachments that were in a designated folder. When they typed in an email address and hit the send button, a script would ask if they wanted to add the email to their own personal address book. This might be a good Community Builder plugin.

Just brainstorming ~

Thumdar

Again, thank you GreyHead.
GreyHead 26 Nov, 2007
Hi thumdar,

Here's the sketch code. Basically it works but there are probably bits that you'll need to tweak to get it to do exactly what you want. The form code is straightforward
<div style="background:#ffff9a; padding:6px;">
<br />
From Email<br />
<input type="text" name="email" value="" />
<br />
<br />
Comments<br />
<textarea name="comments"></textarea>
<br />
<br />
PDF1 <input type="checkbox" name="pdf[]" value="1" /><br />
PDF2 <input type="checkbox" name="pdf[]" value="2" /><br />
PDF3 <input type="checkbox" name="pdf[]" value="3" /><br />
PDF4 <input type="checkbox" name="pdf[]" value="4" /><br />
To: Email 1<br />
<input type="text" name="toemail[]" value="" />
<br />
To: Email 2<br />
<input type="text" name="toemail[]" value="" />
<br />
To: Email 3<br />
<input type="text" name="toemail[]" value="" />
<br />
<br />
<input type="submit" name="submit" value="Submit" /> 
<input type="reset" name="reset" value="Reset" />
<br />
</div>
If you submit this with debug on you'll see that it generated two arrays ('pdf' which is a list of file numbers; and toemail, which is a list of email addresses). And here's a chunk of php to go in the "On Submit code - before sending email" box to process these results.
<?php
// Add emails to recipient list
$toemail = array_unique($_POST['toemail']);
foreach ( $toemail as $add_email ) {
  if ( $add_email != "" ) { 
    $rows[0]->extraemail = $rows[0]->extraemail.",".$add_email;
  }
}

// Create array of file names
$file_path = $mosConfig_absolute_path.'/components/com_chronocontact/files/';
$file_array = array ();
$file_array[1] = "pdf_file_name_1.pdf";
$file_array[2] = "pdf_file_name_2.pdf";
$file_array[3] = "pdf_file_name_3.pdf";

// Attach selected files to email
foreach ( $_POST['pdf'] as $file_index) {
  $attachments[] = $file_path.$file_array[$file_index];
}
?>
This assumes that the files are in a sub-folder called 'files' in the ChronoForms Component folder. It removes duplicate & blank email addresses but doesn't validate them; it still sends to the default To address; and it doesn't check that the files exist (oh, and it's written for Joomla 1.0.x, I think that the path name may be different in 1.5).

Bob
Thumdar 28 Nov, 2007
Wow ~ lots to digest. Thanks Bob, I very much appreciate you going above and beyond to help. When I get into this I will reply further.

Thanks again!🙂
This topic is locked and no more replies can be posted.