Announcement

Collapse
No announcement yet.

Question: Send a GRID by email, is it possible?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question: Send a GRID by email, is it possible?

    How to send the output of a GRID by email?
    Is it possible?


    We know you can send the output of a grid to a PDF, Word, XLS.
    but it is possible send to mail in HTML format?

    thanks.

  • #2
    I have the same question.. is it possible to send a HTML print by email? I want to avoid coding a table in HTML my self... I tried to send a Grid (HTML print) using <iframe src... but it wont appear in the email, just a blank space.
    Any idea?

    Comment


    • #3
      Hi SuperGabo & Misael,
      You can send the output of a grid generated by scriptcase. You need to put this PHP function ob_start(); onScriptinit and ob_end_clean(); onFooter.

      Example to: Store HTML into a variable
      onScriptInit
      PHP Code:
       ob_start(); // buffer start 
      All the output HTML code between 'ob_start()' to 'ob_end_clean()' will be stored in a variable
      onFooter
      PHP Code:
      $html=ob_get_contents();  // store buffer to $html
      ob_end_clean(); // end buffer 
      Now you can send your email using the $html variable.
      Last edited by hirambq; 04-03-2013, 10:36 PM.
      Best Regards
      Hiram BQ

      Comment


      • #4
        Thanks, Hiram.

        I'm using a control application that gets info from a database and sends an email using that information.. so in order to make this work I would need to run the grid first and make the $html global, right?

        Another question, where exactly is this?: "at the start of the output and this at the end"


        Thanks again,
        Misael.

        Comment


        • #5
          The proposed functions come from php. See: http://php.net/manual/en/function.ob-start.php

          You cannot use the grid to generate the output afaik. But you can reuse the sql statement and create your own output. This output (in html format) is then used for emailing. You have to generate the html yourself the way you need.

          -open database
          -set cursor on select
          -start output table
          -for each row
          - create a row <tr>
          --- for each field
          --- create field <td>
          -close table

          send email
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment


          • #6
            Hi Misael lets clarify the example:

            If you want to get the HTML code of a grid generated by scriptcase and store into a PHP variable then
            write this line onScriptinit of your GRID APP:
            PHP Code:
            ob_start(); 
            then onFooter of GRID APP:
            PHP Code:
            $html=ob_get_contents(); 
            ob_end_clean(); 
            This is tested using a grid application (and its working), if you run that code all the grid will be inside the $html variable if you want to see the grid HTML code just echo the $html variable.
            add this line onFooter of GRID APP to see the grid:
            PHP Code:
            echo $html
            So if you want to send an email you will need the $html variable that contains all the HTML code of the grid.
            For example using the mail function of PHP the code will be like this

            add this code onFooter of GRID APP to send an email:
            PHP Code:

            $to 
            "hirambq@scriptcase.net";     
            $from "misael@scriptcase.net";     
            $subject "Hello! This is my grid"
            $headers  "From: $from\r\nContent-type: text/html\r\n"

            mail($to$subject$html$headers); 
            echo 
            "E-mail has been sent....!"
            Note: obviously if you write your own function to generate the HTML grid will be a more clean html code.
            Last edited by hirambq; 04-04-2013, 01:33 AM.
            Best Regards
            Hiram BQ

            Comment


            • #7
              Thanks for clearifying. Never used the ob_ functions. $html=ob_get_contents(); is a great way to get the html data from the buffer. But if you grid is larger and over more pages, how do you solve this? Afaik you only get the page into your html? That's why I alway create a manual php script to fill a string. But intercepting echo is a better way of doing it. Never to old to learn ;-)
              Albert Drent
              aducom software netherlands
              scriptcase partner, reseller, support and (turn-key) development
              www.scriptcase.eu / www.scriptcase.nl

              Comment


              • #8
                Thanks for the explanation!, I'll try it today.

                Comment


                • #9
                  I tried to use this to print a form, but it does not seem to work. Have you figured out how to do this? I can print the screen by creating a button / javascript and apply window.print(); but it will print my buttons too.
                  Last edited by aducom; 06-11-2013, 11:07 AM.
                  Albert Drent
                  aducom software netherlands
                  scriptcase partner, reseller, support and (turn-key) development
                  www.scriptcase.eu / www.scriptcase.nl

                  Comment

                  Working...
                  X