33 APEX_MAIL
You can use the APEX_MAIL
package to send an email from an Oracle APEX application. This package is built on top of the Oracle-supplied UTL_SMTP
package. Because of this dependence, the UTL_SMTP
package must be installed and functioning to use APEX_MAIL
.
APEX_MAIL
contains three notable procedures:
- Use
APEX_MAIL.SEND
to send an outbound email message from your application. - Use
APEX_MAIL.PUSH_QUEUE
to deliver mail messages stored inAPEX_MAIL_QUEUE
. - Use
APEX_MAIL.ADD_ATTACHMENT
to send an outbound email message from your application as an attachment.
APEX installs the database job ORACLE_APEX_MAIL_QUEUE
, which periodically sends all mail messages stored in the active mail queue.
Note:
The APEX_MAIL
package may be used from outside the context of an APEX application (such as from SQL*Plus or from a Database Scheduler job) as long as the database user making the call is mapped to an APEX workspace. If the database user is mapped to multiple workspaces, you must first call APEX_UTIL.SET_WORKSPACE
or APEX_UTIL.SET_SECURITY_GROUP_ID
as in the following examples. The APEX_MAIL
package cannot be used by database users that are not mapped to any workspace unless they have been granted the role APEX_ADMINISTRATOR_ROLE
.
- Example 1
apex_util.set_workspace(p_workspace => 'MY_WORKSPACE');
-- Example 2
FOR c1 in (
select workspace_id
from apex_applications
where application_id = 100 )
LOOP
apex_util.set_security_group_id(p_security_group_id => c1.workspace_id);
END LOOP;
- Configuring Oracle APEX to Send Email
- ADD_ATTACHMENT Procedure Signature 1
- ADD_ATTACHMENT Procedure Signature 2
- GET_IMAGES_URL Function
- GET_INSTANCE_URL Function
- PREPARE_TEMPLATE Procedure
- PUSH_QUEUE Procedure
- SEND Function Signature 1
- SEND Function Signature 2
- SEND Procedure Signature 1
- SEND Procedure Signature 2
See Also:
- Sending Email from an Application in Oracle APEX App Builder User’s Guide
- Oracle Database PL/SQL Packages and Types Reference for more information about the UTL_SMTP package