In the previous posts we have seen the how to send HTML template emails from PHP, NodeJS, PowerShell and we will see Sending HTML Template Emails in Oracle APEX , you can use the built-in email functionality and create a custom PL/SQL process. Here’s a step-by-step guide on how to achieve this:
Step 1: Create an HTML email template:

  • In Oracle APEX, navigate to the “Shared Components” section.
  • Select “Email Templates” and click on “Create” to create a new email template.
  • Provide a name and description for your template.
  • In the “Body” section, enter the HTML content of your email template. You can use APEX substitution strings to dynamically populate data.

Sending HTML template emails from Oracle APEX

Sending HTML template emails from Oracle APEX – Anil Labs


HTML Format
Header

1
 Anil Labs - Test Email Template from Oracle Apex

Body

1
2
3
4
5
6
7
8
9
10
11
12
<p>Dear #DEARNAME#,</p>

<p>I am pleased to inform you that an account has been created for you by our administrator. Your account credentials are as follows:</p>

<p>Username: #LOGINID#</p>
<p>Password: #LOGINPASS#</p>

<p>Please keep this information confidential and do not share it with anyone. If you have any concerns regarding your account or the information provided, please do not hesitate to contact our customer support team.</p>

<p>With your new account, you will be able to access all of the features and services that we offer. This includes [list of services]. We hope that you find our services to be useful and valuable.</p>

<p>Thank you for choosing our platform. We appreciate your business and look forward to serving you in the future.</p>

Footer

1
2
3
4
5
<p>Best regards,</p>

<p>Anil Kumar Panigrahi</p>

<p>CEO & Founder of <b>Anil Labs</b></p>

Sending HTML template emails from Oracle APEX - Email Template -  Anil Labs

Sending HTML template emails from Oracle APEX – Email Template – Anil Labs


Step 2: Create a PL/SQL process from the page designer:

  • Navigate to the page where you want to trigger the email sending process.
  • Go to the “Processing” section and click on “Create” to create a new process.
  • Select “PL/SQL Code” as the process type.
  • In the PL/SQL Code section, write the code to send the email using the APEX_MAIL package. Here’s a sample code snippet to get you started:
Sending HTML template emails from Oracle APEX - Page Designer -  Anil Labs

Sending HTML template emails from Oracle APEX – Page Designer – Anil Labs

1
2
3
4
5
6
7
8
9
10
11
12
13
begin
APEX_MAIL.SEND(
        p_to        => :P4_EMAIL,
        p_from      => '[email protected]',
        p_template_static_id => 'TESTEMAIL',
        p_placeholders       => '{' ||
            '    "DEARNAME":' || apex_json.stringify(:P4_FIRSTNAME) ||
            '    ,"LOGINID":' || apex_json.stringify(:P4_EMAIL) ||
            '    ,"LOGINPASS":' || apex_json.stringify(:P4_PASSWORD) ||
            '}'
       );

end;

Sending HTML template emails from Oracle APEX - Page Designer 2 -  Anil Labs

Sending HTML template emails from Oracle APEX – Page Designer 2 – Anil Labs


In the above code, replace ‘TESTEMAIL’ with the name of your email template. Modify the p_to parameter recipient’s email address dynamically created, p_placeholders to substitute values dynamically from your APEX items into the email template.

Step 3: Save your changes and run the page to test the email sending process from the application page submission.

Remember, before using the APEX_MAIL package, make sure that your Oracle database has been configured for email sending. You need to set up the SMTP server details in the Oracle database and grant appropriate privileges to the APEX schema to use the APEX_MAIL package.

Also, ensure that you have access to the APEX_MAIL package by checking the APEX_MAILpackage’s availability and version in your Oracle APEX installation.


1 Comment

The Era of AI-Powered Low-Code and No-Code Platforms: A Game-Changer in Technology - Anil Labs · August 27, 2023 at 7:27 am

[…] Rise of Low-Code and No-Code AI […]

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *