Forum Stats

  • 3,839,680 Users
  • 2,262,526 Discussions
  • 7,901,038 Comments

Discussions

How can I add attachments from rtf report in oracle apex?

shafiqul
shafiqul Member Posts: 8 Red Ribbon
edited Jun 27, 2021 10:02AM in APEX Discussions

Thanks in advance.......


Following is my Apex Page Submit Process in Apex 20.1.

------------------------------------------------------------

DECLARE

   l_mailid     NUMBER;

   l_report     BLOB;

BEGIN

BEGIN

      l_report :=

         APEX_UTIL.get_print_document (

            p_application_id       => 28062,

            p_report_query_name    => 'QRERROR',

            p_report_layout_name   => 'LYTQRERROR',

            p_report_layout_type   => 'rtf',

            p_document_format      => 'pdf',

            p_print_server => 'https://apex.oracle.com/pls/apex');

    EXCEPTION

      WHEN OTHERS

      THEN

        Proc_Ins_Error_Log (SQLCODE,  SQLERRM));

    END;


    BEGIN

      INSERT INTO TBL_TEST_BLOB (T_BLOB, T_REMARKS)

              VALUES (

                        l_report,

                           'Inserted from apex.oracle.com. Date and Time:'

                        || TO_CHAR (SYSDATE, ' Mon DD, RRRR HH:MIam'));



      COMMIT;

    EXCEPTION

      WHEN OTHERS

      THEN

        Proc_Ins_Error_Log (SQLCODE,  SQLERRM));

    END;


      l_mailid :=

      APEX_MAIL.SEND (

         p_to          => '[email protected]',

         p_from        => '[email protected]',

         p_subj        =>    'APEX_MAIL Apex.Oracle.Com. test subject';

         p_body        => 'dis is test email.',

         p_body_html   =>    '<b>Please</b> review the attachment. Date Time:'

                          || TO_CHAR (SYSDATE, 'RR-MM-DD HH24:MI:SS'));


  

   APEX_MAIL.ADD_ATTACHMENT (

      p_mail_id      => l_mailid,

      p_attachment   => l_report,

      p_filename     =>    TO_CHAR (SYSDATE, 'RRMMDDHH24MISS')

                        || 'OracleApexDotCom.pdf',

      p_mime_type    => 'application/pdf');

   COMMIT;

EXCEPTION

   WHEN OTHERS

   THEN

    Proc_Ins_Error_Log (SQLCODE,  SQLERRM));

END;

/


The mail successfully sent wif an attachment but the attachment can't open / show invalid pdf file.

But when me sent the attachment from my blob column it has no errors. And my query print report successfully wif rtf layout on button click.


My Question Is "How can I send an email from database with attachement from '.rtf' report format"?

Tagged: