3 Replies Latest reply on Jun 11, 2008 10:25 AM by Günter Schenk

    How to maintain format in html email using the send email....

    Level 1
      Does anyone know how to maintain the format in a HTML email using the Send E-mail To Recipients From Recordset behavior?
      When text only is selected instead of HTML text on the Options tab the format of the input is maintained, but when HTML text is selected the email has no format. I have tried to use a replace \n with
      as I have done when hand coding PHP, BUT I am trying to learn to use ADDT. I also tried to use a Custom trigger without success.
      Help!
        • 1. Re: How to maintain format in html email using the send email....
          Günter Schenk Level 4
          Hi Dave,

          in my snippets folder I have this thing which I found on the old MX Kollection forums and which was suggested by the Interakt staff:

          //trigger SendEmail (write content)
          function Trigger_SendEmail(&$tNG) {
          ob_start();
          include("myDynamicContentFile.php");
          $mailcontent = ob_get_contents();
          ob_end_clean();
          $emailObj = new tNG_Email($tNG);
          $emailObj->setTo("me@mysite.com");
          $emailObj->setFrom("from_write@mysite.com");
          $emailObj->setSubject("A new User was added");
          $emailObj->setContent($mailcontent);
          $emailObj->setEncoding("UTF-8");
          $emailObj->setFormat("text");
          $emailObj->setImportance("Low");
          return $emailObj->Execute();
          }
          //trigger SendEmail (write content)

          The only modification is the possibility to include a dynamic PHP file rather than some static text or a HTML file which will also render textarea contents on one line:

          ob_start();
          include("myDynamicContentFile.php");
          $mailcontent = ob_get_contents();
          ob_end_clean();

          That said, it should be possible to define all the "rendering" options in the external PHP file, what would mean to apply the nl2br function there, e.g.: nl2br($row_queryname['columnname'])

          What I´m not sue about is, if you will have to strip the external file´s head and body tags before it´s getting included -- however, please give this a try and tell us how it worked.

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: How to maintain format in html email using the send email....
            Level 1
            Thanks Günter,<br />Sorry, I do not completely understand what I do with the code.<br />also<br />I would like to know what order each part of the code executes.<br />Does the email data go into the table before it sends the email?<br />If the data for the email comes from the table then if I replace all the \n CRs with <break>'s going into the table, then the formatting would print right in the email. I would need a trigger in the right sequence to convert the data to include <break>'s. <br />If the data goes directly from the form, there is no way I can see to affect the formatting.
            • 3. Re: How to maintain format in html email using the send email....
              Günter Schenk Level 4
              Hi Dave,<br /><br />I think you could try with such a BEFORE Custome Trigger:<br /><br />$tNG->setColumnValue("columnname", str_replace('\n','<break>',$tNG->getColumnValue("columnname")));<br /><br />This should replace all \n with html <break> before the textarea data is getting written to the DB<br /><br />-------<br />Sorry, I do not completely understand what I do with the code<br />-------<br /><br />That would be just another approach of including an external "template" file. By default the ADDT Send Email behaviours allow you to either supply a hard-coded text or an external HTML file containing whatever Dynamic Data placeholders -- but no matter what option you decide on, ADDT doesn´t replace all \n with html breaks, so this 3rd approach would let you include an external PHP file where e.g. this line break conversion has already been done by applying the nl2br() function there.<br /><br />Cheers,<br />Günter Schenk<br />Adobe Community Expert, Dreamweaver