APEX_MAIL send results in an HTML table

Apex 3.2

I've written a procedure that sends an email with the data of the apex_workspace_activity_log.
I would try to display that data in a table in the email.
All the world done this before?
CREATE OR REPLACE PACKAGE BODY EFSAPX.p_monitor_page_times AS


  procedure pr_checkelapsed(p_elapsed in number,
                            p_toemail in varchar2) is

    v_text clob;

  begin

    wwv_flow_api.SET_SECURITY_GROUP_ID;
    for x in (select
          application_id,
          application_name,
          page_id,
          elapsed_time
          from
          apex_workspace_activity_log
          where
          application_id = 103
          and elapsed_time > p_elapsed
          and trunc(view_date) > trunc(sysdate-1)
          order by
          elapsed_time desc)

    loop

      v_text := v_text || 'Application No: ' || x.application_id ||chr(10);
      v_text := v_text || 'Application: ' || x.application_name ||chr(10);
      v_text := v_text || 'Page Id: ' || x.page_id ||chr(10);
      v_text := v_text || 'Elapsed Time: ' || x.elapsed_time ||chr(10);
      v_text := v_text || utl_tcp.crlf;

    end loop;

    apex_mail.SEND(p_to    => p_toemail,
                   p_from  => '[email protected]',
                   p_body  => v_text,
                   p_subj  => 'Elapsed Time Metric Warning');

    apex_mail.push_queue('localhost', 25);

  end pr_checkelapsed;

END p_monitor_page_times;
See you soon

Gus

As says below, the real HTML involved is very simple, and there's a lot of documentation available for it.

I normally use SQL/XML for generating HTML fragments with the embedded data:

select
    xmlserialize(
        content
        xmlelement(
            "table"
          , xmlconcat(
                xmlelement(
                    "tr"
                  , xmlconcat(
                        xmlelement("th", 'Application No')
                      , xmlelement("th", 'Application')
                      , xmlelement("th", 'Page ID')
                      , xmlelement("th", 'Elapsed Time')))
              , xmlagg(
                    xmlelement(
                        "tr"
                      , xmlconcat(
                            xmlelement("td", application_id)
                          , xmlelement("td", application_name)
                          , xmlelement("td", page_id)
                          , xmlelement("td", elapsed_time)))
                    order by elapsed_time desc)))
        indent size=2) html_table
from
    apex_workspace_activity_log
where
    application_id = :p_app_id
and elapsed_time > :p_elapsed
and trunc(view_date) > trunc(sysdate-1)

This avoids a lot of tedious messing about with concatenation or substitution in the PL/SQL code and translates the own and valid HTML mark-up with all the tags and attributes in the right place. However as apex_mail API docs notes, the p_body_html parameter must be a complete HTML document (and you will probably need to include any other content and style as well as the table). It's a bit tedious to nest this structure in the query, so a combination method of the lower model for the structure of the base HTML document and this approach to SQL/XML query to generate the table with data structure would be a good idea.

I guess from the wwv_flow_api of . SET_SECURITY_GROUP_ID call that you intend to execute outside a session of APEX? Another option to consider is to create a public page in this app, or as a stand-alone application in the workspace with this query as a region of simple aid report pages/templates, and all the required style embedded in the page. The mail procedure can then use httpUriType.getCLOB to retrieve this page as a complete document which can be passed as p_body_html to apex_mail.send.

Note the requirement that each line in the content cannot exceed 1000 characters. Whatever method you use will have to be built around model/applications are used (where the dash in the code above), or you need to process the content and insert CRLF at the appropriate places before calling apex_mail.send.

Tags: Database

Similar Questions

  • "Apex_Mail.Send" with the body table

    Hello

    I would use the APEX_MAIL. SEND and fill the body with a table.

    Something like this:
    declare
    begin
    
    APEX_MAIL.SEND(
    
      p_to =>'my_test@just_debugging.com',
      p_from=>'my_test@just_debugging.com',
     
      p_body=>  chr(10)||
      APEX_UTIL.TABLE_TO_STRING(my_Table, ',') || chr(10)  || -- <- This does NOT work
      TO_CHAR(Select * from My_Table),  -- <- This does NOT work
      
    
      p_subj=>'My Subject');
     
    -- push the e-mail queue for immediate delivery
    wwv_flow_mail.push_queue(
    P_SMTP_HOSTNAME => 'ip',
    P_SMTP_PORTNO => 'port');
    
    end;
    Does anyone know how to do this?

    Sorry...

    DECLARE
       p_vc_arr2   htmldb_application_global.vc_arr2;
       p_string    VARCHAR2 (2000);
    BEGIN
    
    SELECT ename
       BULK COLLECT INTO p_vc_arr2
         FROM emp
        WHERE deptno = :p84_select_deptno; -- Or remove condition.
    
       p_string :=
         HTMLDB_UTIL.table_to_string (p_vc_arr2, ':');
    
    APEX_MAIL.SEND(
    
      p_to =>'my_test@just_debugging.com',
      p_from=>'my_test@just_debugging.com',
    
      p_body=>  p_string
    
      p_subj=>'My Subject');
    
    -- push the e-mail queue for immediate delivery
    wwv_flow_mail.push_queue(
    P_SMTP_HOSTNAME => 'ip',
    P_SMTP_PORTNO => 'port');
    
    end;
    

    In http://apex.oracle.com/pls/otn/f?p=31517:84:2900701551472314

    It should be something like this...

  • Help! &gt; How to send a dynamic HTML table as an email?

    Hello


    I want to send a dynamic html table as an email


    I'm using php/mysql and I have a mysql database


    I have a table dynaimc restrained some data from the database


    I have a form with a text box to write the email and a button "submit"


    I want to send the picture (or the information in the table) when I send the form


    is this possible?


    Help, please!

    OK, now I have you.  You create a queary to select the data you want, and then copy the following code

    $data = mysqli_query ($dbc, $query) or die (mysqli_error ($dbc));

    While ($row = {mysqli_fetch_array ($data))}

    Mail to the owner of the form

    $header = "from: [email protected]\n".

    . "Reply-To: $email\n";

    $subject = 'DB in emails data';

    $email_to = "[email protected]";

    $message =

    $row ["FirstName"].

    $row ['last_name']

    ;

    }

    mail ($email_to, $subject, $message, $header);

    So, for each column, you will enter in this

    $row ["FirstName"].

    So if the column reported, you would put

    $row ["State"].

    I hope this is the answer you are looking for.

    Gary

  • Do not get the email sent by APEX_MAIL.send in some areas

    Hello

    I am trying to send an email using apex_mail.send. I do mail successfully in my gmail account, but in my identification of email to office and an area that I do not receive the mail.

    No error shown against these IDs, but do not in the APEX_MAIL_LOG table it becomes mail.

    One has an idea of what can be the issue.

    Thank you

    Sanjaya

    Hi all

    Thanks for your reply. Indeed, the problem was with the receiving server.

    Thank you

    Sanjaya

  • How can I filter the data and display it in the html table?

    Hello

    How do I filter data that contains the database table and already displayed in html table, then when the user write a data to filter or search, it will automatically display the data in html table. ?

    can someone help me to do this? Here is my php code for the table that will display the data:

    <?php
      $servername = "localhost";
      $username = "root";
      $password = "pass";
      $dbname = "ses";
       
       
      // Create connection
      $conn = new mysqli($servername, $username, $password, $dbname);
      // Check connection
      if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
      }
       
      $sql = "SELECT No, Calon, ID, Jurusan FROM candidates";
    
      $result = $conn->query($sql);
      ?>
    
    <?php
      if ($result->num_rows > 0) {
      echo "<table >
    
      <tr>
      <th>NO</th>
      <th>Candidate</th>
      <th>ID Number</th>
      <th>Programme</th>
      <th>Edit</th>
      <th>Delete</th>
      </tr>";
      // output data of each row
      while($row = $result->fetch_assoc()) {
      echo "<tr>
      <td align='center'>" . $row["No"]. "</td>
      <td>" . $row["Calon"]. "</td>
      <td>" . $row["ID"]. " </td>
      <td>" . $row["Jurusan"]. "</td>
      <td align='center'><a href='main2.php?edit=".$row["No"]."'>Edit</a></td>
      <td align='center'><a href='delete.php?del=".$row["No"]."'>Delete</a></td>
      </tr>";
      }
    
      echo "</table>";
      } else {
      echo "0 results";
      }
      $conn->close();
      ?>
    

    hope someone can help me with this.

    Thank you.

    You must first create a search form for the user to enter a search word:

    Then create a page named search_page.php and insert the following code into it and save it. The code in red below Gets information from the search form field name = "Calon" and the SQL query finds in the "Calon" database field for a game.

    <>

    $servername = "localhost";

    $username = 'root ';

    $password = "pass";

    $dbname = 'his ';

    Create the connection

    $conn = new mysqli ($dbname, $servername, $username, $password);

    Check the connection

    If {($conn-> connect_error)

    Die ("connection failed:".) $conn-> connect_error);

    }

    $Calon = trim($_POST['Calon']);

    $sql = (' SELECT no, Calon, ID, Jurusan candidates WHERE Calon = "'.") $Calon.' » ") ;

    $result = $conn-> Query;

    ?>

    <>

    If ($result-> num_rows > 0) {}

    ECHO '.

    ";

    each line output

    While ($row = {$result-> fetch_assoc())}

    ECHO '.

    ";

    }

    ECHO '.

    NO. Candidate Identification number Program Edit Delete
    " . $row ["no"]. " " . $row ["Calon"]. " " . $row ['ID']. " " . $row ["Jurusan"]. " Edit Delete
    ";

    } else {}

    echo "0 results."

    }

    $conn-> close();

    ?>

  • JSON data in HTML table

    I'm new to jQuery, animate edge and this Forum... and pretty novice to HTML5 and CSS3, so I could really use a help please :-)

    I have a JSON file with many records.  I wish that each record to represent a row in an html table.  The JSON file gets written each night courses, and the number of records in the JSON file will often change.  I want to write the values of the file in a dynamic html table and then use different animations to set the table on the stage!  Possible?  Or is there a better way?

    My JSON example:

    [{'id': 1,}]

    'Division': 'Austin ',.

    'txt_one': 9,.

    'txt_two': 5,.

    'txt_three': 20,.

    "txt_four": 5

    },

    {"id": 2}

    'Division': 'Houston ',.

    'txt_one': 0,

    "txt_two": 4.

    'txt_three': 0,

    'txt_four': 7

    },

    {"id": 3}

    "Division':"Phoenix. "

    'txt_one': 1,.

    'txt_two': 2.

    "txt_three": 3.

    "txt_four": 6

    }]

    (1) the html option (table symplistic).

    (A) code:

    var myList = {lines: []}

    {'id': 1, 'Division': 'Austin', 'txt_one': 9, "txt_two": 5, "txt_three": 20, "txt_four": 5},

    {'id': 'Division' 2: "Houston", "txt_one": 0, "txt_two": 4, "txt_three": 0, "txt_four": 7},.

    {'id': 3, 'Division': 'Phoenix', 'txt_one': 1, 'txt_two': 2, 'txt_three': 3, 'txt_four': 6}

    ]};

    var lines ="";

    .each $(myList.rows, {function(index,item)}

    "lines += '.'+' + item.id"+ point. "Division.'+ item.txt_one +''+ item.txt_two +''+ item.txt_three +''+ item.txt_four +'";

    } );

    .html ("$("Text") sym.

    "+ lines +".
    ");

    SYM. $("table") .css ("width", sym.$("Text").width ());

    SYM. $("table, td") .css ({'border': "1px solid black", "border-spacing": "5px"})

    SYM. $("tr") .css ("background", "#acc5a0");

    SYM. $("td") .css ("text-align", "center") .css ("color", "white");

    (B) back on stage:

    (2) the display option.

    Could you please send a file with your model of symbol?

    I mean your line template.

  • HTML &lt; Table &gt; tag in Flash

    I have a flash flipbook, I need to implement the HTML < Table > tag inside flash,
    How to integrate into flash because flash accepts only basic HTML tag...
    I HAV FLA, SWF, JS and the HTML, what file I need to change...
    Please guide me...

    There is nothing that you can change in all files that will result in Flash support html table tags

  • Firefox can't find the text on the HTML table cells

    Firefox cannot find (Ctrl + F) the text inside HTML tables, as in
    http://www.dip-Badajoz.es/BOP/ventana_anuncio.php?id_anuncio=22714 & FechaSolicitada = 2008-02-20
    If you try to search "Solano", Firefox will not find any matches, but "Solano" is here. This works fine on Chrome, for example.

    Thank you

    I am also on Linux, but if I start a version of Firefox 6 via Wine the I don't have a problem with a search for "Solano".

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions of the origin of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • Display HTML table in the BBUI screen

    I want to write an application that displays a custom calendar (month view). Now, I use java script to render an HTML table, and insert this code in the data screen as below.

    function viewSelectedMonth() will make only the HTML for the table. But when I run the action menu does not work. Could you tell?


       


           
    Help

           
    On

           
    Parameters

       


        
        


       


           

    Home

           
    Toast


           

    Today


    Hi there, I don't have an exact answer as to why your code behaves like that.

    The best thing I can say is that you use Web Inspector to debug your application. If there are errors as they appear in the Console of the Web Inspector, and you will be able to solve much better.

    More info @ https://developer.blackberry.com/html5/documentation/v2_2/getting_started_web_inspector.html

  • Problem with HTML table.

    Urgent please. I have a table with two rows. In each line, I'll add a few separate images in columns/cells. On the first line, the images will fill all the columns. But (!) on the first line, I'll add pictures only on left (fixed to the left) and the right (fixed to the right) and I want every cell of these two broad 8px, so I can keep the Middle wide enough to add text and empty. But I can't do it!

    Here's a JSfiddle my work online.

    http://jsfiddle.NET/mdermez32/pcmz4ysk/2/

    Why can't I just have two rows of a table and each line have two or more cells with fixed width?

    You can, but you have no guarantee in a way that will be rendered (or display) in all browsers on every computer and mobile device out there.

    HTML tables are elastic by nature and love to develop according to their content and fill any container they are in (div block etc.). Trying to control a single table to perfection perfect pixel is bound to frustrate you.

    Nested tables has long been the most reliable solution for the specific page layouts such as you are aiming for.

  • Create a Page item: stop and start the HTML Table presentation - location?

    Where is the "Create Item-> stop and start HTML Table Layout Page" located at? I can't find it.

    kilo1-1 wrote:
    Where the "create point Page--> stop and start HTML layout table" is located at? I can't find it.

    4.2 elements 'Stop and start in HTML table' are replaced by setting new Start grid in grid presentation properties of each element.

    (Please always indicate which version APEX your question relates to.)

  • Display the values of the Page element in HTML table

    Hi all

    could you please help me with the below? I want to have a table in the HTML area and to display in the table of elements of the Page of the page.

    I got the code like this:
    {
    < table >
    < tr > < td > & P1_ECEMEA_ASSISTANCE < table > < /tr >
    < tr > < td > & P1_ECEMEA_WIP < table > < /tr >
    < /table >
    }
    It shows the element of the Page names in the form of text, not the values.

    However, this code without the tags table:
    {
    ECEMEA request for Assistance of the CQT: & P1_ECEMEA_ASSISTANCE.
    ECEMEA CQT Work in Progress: & P1_ECEMEA_WIP.
    }
    Works and Page element values are displayed.

    Is it possible to display the values of the Page element in the HTML table at all or should I use a different method to show the values in a table? The above is only an excerpt of the code. I need to display about 30 items in Page, put in shape in a table with headers.

    Please let me know what kind of region is the best to use, or if I have to use only a few symbols of escape in the table code...

    Thank you and best regards,

    Vladimir

    Vladimir,

    Looks like you're missing the period after the substitution variables.

    {
    
    &P1_ECEMEA_ASSISTANCE.
    &P1_ECEMEA_WIP.
    }

    -D.

  • JSF component to create a html table view

    Jdev 11.1.1.4

    I would like to know what is the preferred jsf component create a view in an HTML table.

    My screen must have a 'head of column table' and 'line the table header '. It is composed of several rows and columns. In each cell, I need to insert a different inputText mapped to the different attributes of VO. I have many attributes of VO... (one per cell). Something like a MS-Excel crosstab table.

    I am currently using a real html table, but I'm having some problems when the contents are adjusted inside a cabinet (sometimes the right side of the table out of the box of control panel). I also have problems with the help toolltip (property shortdesc) text that sometimes does not display exactly where are the input fields and the shadow of this ToolTip apears incorrectly overlapping content (in fact the ToolTip apperars in one place and he the shadow in a different place from the screen like a gray rectangle.)

    I don't know if all this strange behaviors could be caused due to the use of html tables.

    Hello

    Check this box
    http://MyFaces.Apache.org/Trinidad/Trinidad-API/tagdoc/trh_tableLayout.html

    Kind regards

  • My html table does not appear on the 2nd tab on the Panel (muse widget)

    The same table works fine on the first tab, however when I try to click on the second table in the page mode or overview of the browser on browser, my table is not displayed. Tips to solve this problem?

    If I get this right, you use the tabbed panel widget to display an HTML table in each of the tabs. If this is the case, please make sure that you insert the HTML content on each content area of the tab respectively. To check this, switch between tabs in design mode to check your content.

    Thank you

    Vinayak

  • HTML Table tag...

    Dear all,

    I have an obligation to have simple tabular data.
    If I managed to do it like this
    <f:verbatim>
                    <table width="100%" border="1" class="column" cellpadding="3" cellspacing="0">
                      <tr bgcolor="#ECEDF0">
                        <td><af:outputText id="ot2" value=" " escape="false"/></td>
                        <td><af:outputText id="ot3" value="Status" inlineStyle="margin:4.0px;"/></td>
                        <td><af:outputText id="ot4" value="Date"
                                   inlineStyle="margin:4.0px;"/></td>
                        <td><af:outputText id="ot5" value="Upd By"
                                inlineStyle="margin:4.0px;"/></td>
                        <td><af:outputText id="ot6" value="Co-ordinator" inlineStyle="margin:4.0px;"/></td>
                      </tr>
                      <tr>
                      <td  bgcolor="#ECEDF0"><af:outputText id="ot12" value="Overall"
                                   inlineStyle="margin:4.0px;"/></td>
                        <td  bgcolor="#FFFDFD"><af:outputText id="ot8"
                                   value="#{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' : bindings.xx.inputValue }
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  '(' }
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  bindings.xx.inputValue }
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  ')' }"
                                   inlineStyle="width:150px; margin:4.0px;"/></td>
                        <td><af:outputText id="ot9"
                                   value="#{bindings.xx.inputValue}"
                                   inlineStyle="margin:4.0px;">
                      <af:convertDateTime pattern="#{bindings.xx.format}"/>
                    </af:outputText></td>
                        <td><af:outputText id="ot10" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue}"/></td>
                        <td><af:outputText id="ot11" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue}"/></td>
                      </tr>
                      <tr>
                      <td  bgcolor="#ECEDF0"><af:outputText id="ot22" value="Tech"
                                   inlineStyle="margin:4.0px;"/></td>
                        <td><af:outputText id="ot13" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' : bindings.xx.inputValue }
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  '('}
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  bindings.xx.inputValue}
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  ')'}"/></td>
                        <td><af:outputText id="ot14" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue}">
                      <af:convertDateTime pattern="#{bindings.xx.format}"/>
                    </af:outputText></td>
                        <td><af:outputText id="ot16" value="#{bindings.xx.inputValue}"
                                   inlineStyle="margin:4.0px;"/></td>
                        <td><af:outputText id="ot15" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue}"/></td>
                      </tr>
                      <tr>
                      <td  bgcolor="#ECEDF0"><af:outputText id="ot17" value="Legal"
                                   inlineStyle="margin:4.0px;"/></td>
                        <td><af:outputText id="ot18" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' : bindings.xx.inputValue }
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  '(' }
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  bindings.xx.inputValue }
                                          #{bindings.xx.inputValue == null || bindings.xx.inputValue == '' ? '' :  ')' }"/></td>
                        <td> <af:outputText id="ot19" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue}">
                      <af:convertDateTime pattern="#{bindings.xx.format}"/>
                    </af:outputText></td>
                        <td><af:outputText id="ot20" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue}"/></td>
                        <td><af:outputText id="ot21" inlineStyle="margin:4.0px;"
                                   value="#{bindings.xx.inputValue}"/></td>
                      </tr>
                    </table>
                  </f:verbatim>
    You can see that there are a lot of style...
    I decided to use h:panelGrid but it doesnot give me much comfort wrt style... especially if I want to do for a cell.
    It is for me a correct output... no errors except under the direction of jdeveloper gives me redmarks...

    I know this isn't a code of good practice and not recommended but is at - it another alternative...?
    Any idea on 3rd lib left... as (html:table... html:td... html:tr. ike stuff).

    Kind regards
    Sicard.

    JDeveloper 11.1.1.4.0

    Arrrrrrrgs! ... your code looks like a recipe from hell (Smiley)

    Instead, try to Trinidad

    TRH:tableLayout
    TRH:rowLayout
    TRH:cellFormat

    You can add libraries of the Trinity to your ADF Faces project by mosue right click in the Compoennet Palette and choosing "Edit tag libraries". Select the 'Trinity HTML' library

    Frank

Maybe you are looking for

  • I want to use gmail to send the scann pdf copiHP 8500 scan

    I want to use gmail to send copies of scanned pdf document. My HP 8500 allows only Outlook. I have windows 7

  • Qualcomm 3 G module error message "no signal available.

    I have Acer Aspire 1830 with inside Qualcomm 3 G module. After I insert the card GSM SIM, then I opened the Acer 3 G Connection Manager, but he says "No Signal available. I don't know why but in the Device Manager, 3 G Modul detected and all the driv

  • I need to replace my WRT54G?

    I have a WRT54G ver 3 I installed the firmware to verersion 4.21.1 as I am trying to add a new Windows 7 laptop with a Wireless N adapter to my home wireless network.  I can still connect my old XP SP3 computer to the Internet, but the new laptop sti

  • Windows update ends

    Good then last night when I turned off my computer it started 16 download Windows updates. I have Windows 7. I went to sleep and let it download overnight. However, when I wake up today, it is still downloading. It is 15/16 is not as if he hasn't dow

  • Smartphones Blackberry blackBerry help

    Hello I was wondering if I went on vacation, and if I had to use my bbm would pay for it? I understand the fact that I would be charged for roaming, but if I had to pay for roaming, my bbm would still be free? my plan is currently free bbming.