AdithMana
AdithMana

Reputation: 56

Automated email in Oracle apex

I need to send an automated email in Oracle APEX after DB backup is done. Is there any way to ensure the DB Backup process is complete?

Upvotes: 3

Views: 2436

Answers (1)

bprasanna
bprasanna

Reputation: 2453

If DB Backup is initiated through an action like Submit button, we can invoke a PL/SQL Script to send an email through new After Submit process.

Following is the APEX method used to send email:

apex_mail.send(
    p_to   => to_list,   -- change to your email address
    p_from => sender, -- change to a real senders email address
    p_bcc => bcc_list,
    p_body      => l_body,
    p_body_html => l_body_html,
    p_subj      => subject);

Navigation:

Page Definition -> Page Processing -> Processes 

Following is a sample PL/SQL function created in SQL Workshop to send an email:

create or replace function sendemail(sender in varchar2, receiver in varchar2, subject in varchar2, content in CLOB, signature in varchar2) return boolean is
    sent_status boolean := false;
    l_body clob;
    l_body_html clob;
begin
    l_body := 'To view the content of this message, please use an HTML enabled mail client.'||utl_tcp.crlf;

    l_body_html := '<html>
        <head>
            <style type="text/css">
                body{font-family: Arial, Helvetica, sans-serif;
                    font-size:10pt;
                    margin:30px;
                    background-color:#ffffff;}

                span.sig{font-style:italic;
                    font-weight:bold;
                    color:#811919;}
             </style>
         </head>
         <body>'||utl_tcp.crlf;
    l_body_html := l_body_html ||content || utl_tcp.crlf;
    l_body_html := l_body_html ||' <span class="sig">'||signature||'</span><br />'||utl_tcp.crlf;
    l_body_html := l_body_html ||'</body></html>';
    apex_mail.send(
    p_to   => receiver,   -- change to your email address
    p_from => sender, -- change to a real senders email address
    p_bcc => sender,
    p_body      => l_body,
    p_body_html => l_body_html,
    p_subj      => subject);
    sent_status := true; 
    return sent_status;
end;

Upvotes: 3

Related Questions