UTL_MAIL消息属性调用OWA_UTIL.cellsprint过程Oracle [英] UTL_MAIL message attribute calling OWA_UTIL.cellsprint procedure Oracle

查看:102
本文介绍了UTL_MAIL消息属性调用OWA_UTIL.cellsprint过程Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下html代码段,我想在我的程序中通过电子邮件发送. 如何将其放在UTL_MAIL的message属性中. 我应该将其放在某个变量中吗?如果可以,怎么办?

Hi I have the following html snippet, I want to send via email in my procedure. How do I put that in my message attribute of UTL_MAIL. Should I put it in some variable and if so how?

如果有更好的方法,我也想探索一下.下面有两个选择.我无法使MESSAGE属性起作用.

If there is any better way, I would love to explore that too.I have two options below.I am not able to make the MESSAGE attribute work.

OPTION 1
   DECLARE
    BEGIN
    UTL_MAIL.SEND (
      sender       => 'xxx@yyy',
      recipients   => 'abc@xyz',
      subject      => 'Hi',
      MESSAGE      => 
      OWA_UTIL.cellsprint (p_theQuery =>'SELECT   a1,b1,c1,d1
                     FROM     test1
                     WHERE    a1 > 1
                     ORDER BY a1',
      p_max_rows=>'10',p_format_numbers => NULL),

      mime_type    => 'text/html; charset=us-ascii');

    END;

    ----------------------------------------------------------------
    OPTION2
    Declare
        Begin
        ....
        ......
        UTL_MAIL.SEND (
          sender       => 'xxx@yyy',
          recipients   => 'abc@xyz',
          subject      => 'Hi',
          MESSAGE      => ***
          mime_type    => 'text/html; charset=us-ascii');
        *** 
        HTP.P ('<HTML>');
         HTP.P ('<HEAD>');
         HTP.P ('<TITLE>Duplicate Records</TITLE>');
         HTP.P ('</HEAD>');
         HTP.P ('<BODY>');
         HTP.P ('<H1>Duplicate Records</H1>');
         HTP.P ('<TABLE BORDER="1 ">');
         HTP.P ('<TR><TH>HIERARCHY</TH><TH>Org Long NAME</TH></TR>');

         FOR idx IN (SELECT   a1,b1,c1,d1
                     FROM     test1
                     WHERE    a1 > 1
                     ORDER BY a1 LOOP
          HTP.P ('<TR>');
          HTP.P ('<TD>' || idx.a1 || '</TD>');
          HTP.P ('<TD>' || idx.b1 || '</TD>');
          HTP.P ('<TD>' || idx.c1 || '</TD>');
          HTP.P ('<TD>' || idx.d1 || '</TD>');
          HTP.P ('</TR>');
         END LOOP;

         HTP.P ('</TABLE>');
         HTP.P ('</BODY>');
         HTP.P ('</HTML>');


        END;

推荐答案

UTL_MAIL.send的message只是一个VARCHAR2参数,它使用字符串作为参数.

UTL_MAIL.send's message is just a VARCHAR2 parameter, it takes a string as a parameter.

HTP.POWA_UTIL.cellsprint是过程,而不是函数,因此不能用于将值传递给邮件.它们仅设计用于基于Web的应用程序,不适用于邮件之类的其他用途.

HTP.P and OWA_UTIL.cellsprint are procedures, not functions, so they cannot be used to pass a value to the mail. They're designed for use in a web-based application, and not suitable for other purposes like mail.

如果需要,可以使用HTF中的函数,但是在您的情况下,您已经编写了html,因此也可以将其直接传递给消息:

You could use the functions in HTF if you want, but in your case you've already written your html so you may as well just pass it directly to message:

UTL_MAIL.SEND (
      sender       => 'xxx@yyy',
      recipients   => 'abc@xyz',
      subject      => 'Hi',
      MESSAGE      => '<HTML>...'
      mime_type    => 'text/html; charset=us-ascii');

这篇关于UTL_MAIL消息属性调用OWA_UTIL.cellsprint过程Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆