Table of Contents
Enable users to send emails from your application by creating email templates.
Note:
Before you can send email from an application, your Instance administrator must log in to Oracle Application Express Administration Services, navigate to the Instance Settings page and configure Email attributes.
See Also:
"Configuring Email" in Oracle Application Express Administration Guide
"APEX_MAIL" in Oracle Application Express API Reference
Parent topic: Managing Shared Components
Define email templates for your application. Email templates include both an HTML Format and a Plain Text Format.
To define an email template:
The Shared Components page appears.
Tip:
To get started, review the sample email templates available under Sample Templates on the right side of the page. To load a sample email template, simply select it. See "Viewing Sample Email Templates".
Tip:
For Email Subject, HTML Format or Plain Text Format, support substitution strings using the format #STRING_NAME#
. You can pass in values for these strings using the APEX_MAIL
API.
APEX_MAIL
APIs.APEX_MAIL
API.APEX_MAIL
API.
Consider the following example:
begin
apex_mail.send (
p_to => 'steven.king@example.com',
p_template_static_id => 'ORDER_CONFIRMATION',
p_placeholders => q'~
{
"CUSTOMER_NAME": "Steven King",
"ORDER_NUMBER": 1234,
"ORDER_DATE": "02-Feb-2018",
"SHIP_TO": "Steven King",
"SHIPPING_ADDRESS_LINE_1": "2004 Charade Rd",
"SHIPPING_ADDRESS_LINE_2": "Seattle, Washinton",
"ITEMS_ORDERED": 3,
"ORDER_TOTAL": "$ 1,200.99",
"ORDER_URL": "http://domain/apex/f?p=&APP_ID"
}~' );
apex_mail.push_queue;
end;
See Also:
Parent topic: Managing Email Templates
View the sample email templates: Load Order Details, Load Event Reminder, or Load Scheduled Outage.
To view sample email template:
The Shared Components page appears.
Load Order Details
Load Event Reminder
Load Scheduled Outage
begin apex_mail.send ( p_to => email_address_of_user, p_template_static_id => '', p_placeholders => '{' ' "CUSTOMER_NAME":' || apex_json.stringify( some_value ) ' ,"ITEMS_ORDERED":' || apex_json.stringify( some_value ) ' ,"MY_APPLICATION_LINK":' || apex_json.stringify( some_value ) ' ,"ORDER_DATE":' || apex_json.stringify( some_value ) ' ,"ORDER_NUMBER":' || apex_json.stringify( some_value ) ' ,"ORDER_TOTAL":' || apex_json.stringify( some_value ) ' ,"ORDER_URL":' || apex_json.stringify( some_value ) ' ,"SHIPPING_ADDRESS_LINE_1":' || apex_json.stringify( some_value ) ' ,"SHIPPING_ADDRESS_LINE_2":' || apex_json.stringify( some_value ) ' ,"SHIP_TO":' || apex_json.stringify( some_value ) '}' ); end;
Parent topic: Managing Email Templates
Provide dynamic text in your email templates using existing substitution modifiers.
For security reason, the values substituted for the placeholders (#NAME#
) in the email templates are automatically escaped based on the context. In other words, HTML formatted templates include HTML escaping and Plain Text templates do not. If this is not the desired behavior for your environment, you can provide dynamic text which contains HTML tags using the existing substitution modifiers:
#NAME!RAW#
- Text is substituted as is.
#NAME!STRIPHTML#
- All HTML tags are removed.
Extending the Email Templates
For example, you can extend the HTML Format - Body template with:
<tr> left”>Additional Information</th> <td>#ADDITIONAL_INFO!RAW#</td> </tr>
Similarly, you can extend the Plain Text Format template with:
Additional Info: #ADDITIONAL_INFO!STRIPHTML#
Sample PL/SQL
The PL/SQL code would look similar to this:
begin
apex_mail.send (
p_to => 'steven.king@example.com',
p_template_static_id => 'ORDER_CONFIRMATION',
p_placeholders => q'~
{
"CUSTOMER_NAME": "Steven King",
"ORDER_NUMBER": 1234,
"ORDER_DATE": "02-Feb-2018",
"SHIP_TO": "Steven King",
"SHIPPING_ADDRESS_LINE_1": "2004 Charade Rd",
"SHIPPING_ADDRESS_LINE_2": "Seattle, Washinton",
"ITEMS_ORDERED": 3,
"ORDER_TOTAL": "$ 1,200.99",
"ORDER_URL": "http://domain/apex/f?p=&APP_ID"
"ADDITIONAL_INFO": "We plan to deliver your ordered items <strong>tomorrow morning between 08:00 and 09:00</strong>
}~' );
apex_mail.push_queue;
end;
Parent topic: Managing Email Templates
Edit or delete existing email templates.
To edit or delete an email template:
The Shared Components page appears.
Parent topic: Managing Email Templates