Forums

Email previously saved results

wizdum 08 Sep, 2008
Chronoforms 2.5

Is there a way to re-email the 'saved form data'? Maybe with a custom script?
We have been having some email problems and need to resend the data formatted by the email template so the office can file it in their usual manner.

Can i possibly pull the entries from the database and run them through the script that creates the email template?
Max_admin 08 Sep, 2008
Hi wizdum,

yes you can do this, but you need to write SQL to get the form data stored and loop through every one and apply the template code and send an email, the idea is easy but it needs the code written well!

look at the autogenerated code for the table name and search here for SELECT to see how you can write a SQL select statement and loop results and send the email with Jutility::sendMail

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
wizdum 08 Sep, 2008
Thanks Max.

Ill see if the client wants to pay for the custom work :wink:
Max_admin 08 Sep, 2008
No problems!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
warmbeach 13 Nov, 2013
Hello,

I need to be able to resend emails with previously saved results as well.

Does anybody have the script already?

Thanks!
Max_admin 14 Nov, 2013
Hello,

You can do this by using a "DB Record loader" to load the data then use an email action, pay attention to the structure of the data in the $form->data array as this affects how you can write the strings in the email.

If data is loaded under a model id then you need to use: {model.field_name}

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
warmbeach 14 Nov, 2013
Hello Max,

Thanks for your prompt reply and a great suggestion. I was able to get the "DB Record Loader" to work with Data Load Type = First Record but not All of them, which is what I need...

Am I missing something?

Thanks a lot!
warmbeach 14 Nov, 2013
Hi Sloan,

Thank you!
I forgot to mention that I am using the DB Multi Record Loader action.
And I know I can loop the records through PHP:
<?php
foreach($form->data['eventvolunteers'] as $volunteer){
echo $volunteer['fname']." ".$volunteer['lname'];
echo '<br />';
} ?>

Yes, I do need to send one email per record... So how do I put my email action inside the loop??

THanks for your help!
warmbeach 14 Nov, 2013
That is unfortunate... I guess I'll just give up trying.

Thanks!
Max_admin 15 Nov, 2013
Hi,

If each record has an email address you need to use then just loop through all records and store all addresses in an array, then implode it and use that value as the dynamic "TO" or "BCC":


//your array of address is $emails
$form->data['dto'] = implode(",", $emails);


then use "dto" in the dynamic to or bcc, if you use bcc then you must have at least 1 static "to" address, I think so.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
warmbeach 15 Nov, 2013
Hi,

Thanks for the suggestion, but I actually need to send out dynamic emails (about 65 of them) to one recipient...
GreyHead 19 Nov, 2013
Hi Dan,

Here's the main mailer code. This covers several different Joomla! versions, I think that in fact the 1.6-2.5 code would also work on Joomla! 3:
        if ( $jversion->RELEASE <= 1.5) {
          if ( !count( $replyto_name ) ) {
            $replyto_name = '';
          }
          $email_sent = JUtility::sendMail( $from_email, $from_name, $recipients, $subject, $email_body, $sendas, $cc_emails, $bcc_emails, $email_attachments, $replyto_email, $replyto_name );
        } elseif ( $jversion->RELEASE > 1.5 && $jversion->RELEASE < 3 ) {
          $mail =& JFactory::getMailer();
          $email_sent = $mail->sendMail( $from_email, $from_name, $recipients, $subject, $email_body, $sendas, $cc_emails, $bcc_emails, $email_attachments, $replyto_email, $replyto_name );
        } elseif ( $jversion->RELEASE > 2 ) {
          $mail =& JMail::getInstance();
          $mail->setSender(array( $from_email, $from_name ));
          $mail->addRecipient($recipients);
          $mail->setSubject($subject);
          $mail->setBody($email_body);
          $mail->isHTML((bool) $sendas == 'html' );
          $mail->Encoding = 'base64';
          $mail->addAttachment($email_attachments);
          $mail->addCC($cc_emails);
          $mail->addBCC($bcc_emails);
          $mail->addReplyTo(array($replyto_email, $replyto_name));
          $email_sent = $mail->Send();
        }

Bob
warmbeach 19 Nov, 2013
Thanks, Bob!

I'll give it a try! Hopefully it will work on Joomla! 3.
This topic is locked and no more replies can be posted.