Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, David.

Asked: May 22, 2023 - 9:02 pm UTC

Last updated: May 23, 2023 - 4:44 am UTC

Version: Oracle Database 11g Release 11.2.0.1.0

Viewed 1000+ times

You Asked

We have been using an older version of Apex for about 10 years now and now want to set up email capability for sending reports as attachments. I have scoured the internet for the requirements to use but am getting confused with all the different answers. We need to connect to an external smtp server. What exactly do I need to get in place to get this to work on this older version of Apex? Please let me know if you need more info to better answer this question. Thank you.

and Connor said...

APEX 4 ? wow :-)

Easiest way would be to install UTL_MAIL and use that.

conn sys/password as sysdba
@$ORACLE_HOME/rdbms/admin/utlmail.sql
@$ORACLE_HOME/rdbms/admin/prvtmail.plb

conn sys/password as sysdba
alter system set smtp_out_server='smtp.domain.com' scope=spfile;

-- instance restart only necessary in 10gr1.
shutdown immediate
startup

begin
  utl_mail.send_attach_varchar2 (
    sender       => 'akstom@mysite.com',
    recipients   => 'recipient1@mysite.com,recipient2@mysite.com',
    cc           => 'recipient3@mysite.com',
    bcc          => 'recipient4@mysite.com',
    subject      => 'This is the subject',
    message      => 'This is the message',
    attachment   => 'This is the text attachment.',
    att_filename => 'filename.txt'    
  );
end;
/


but come on ... its time to upgrade!


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library