Select and Display the table in oracle APEX mail body

北慕城南 提交于 2019-12-03 09:32:38

Yes you can, by sending an HTML email - but you have to construct the HTML yourself. For example:

declare
   l_body_text long;
   l_body_html long;
begin
   l_body_html := '<table style="border-collapse: collapse; border: 1px solid black"><tbody>'
                  || '<tr>'
                  || '<th style="background-color: #eef; border: 1px solid black">ENAME</th>'
                  || '<th style="background-color: #eef; border: 1px solid black">DNAME</th></tr>';

   for r in (select ename, dname from emp)
   loop
      l_body_html := l_body_html || '<tr><td style="border: 1px solid black">' 
                     || r.ename || '</td><td style="border: 1px solid black">'
                     || r.dname|| '</td></tr>';
   end loop;
   l_body_html := l_body_html || '</tbody></table>';

   l_body_text := 'Plain text version';

   apex_mail.send
      ( p_to        => 'you@there.com'
      , p_from      => 'me@here.com'
      , p_body      => l_body_text
      , p_body_html => l_body_html
      , p_subj      => 'Your report'
      );
end;

Note:

  1. You need to supply a plain text alternative in case the recipient cannot receive HTML emails.
  2. You need to apply any styling in-line - you cannot reference a CSS file.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!