APEX_MAIL : Send Emails from PL/SQL
The APEX_MAIL package provides an API for sending emails from PL/SQL.
oracle miscconfigurationintermediate
by OracleDba
45 views
The APEX_MAIL package provides an API for sending emails from PL/SQL.
123456789101112
declare
l_username varchar2(30) := 'APEX_210100';
begin
dbms_network_acl_admin.append_host_ace(
host => 'localhost',
lower_port => 25,
ace => xs$ace_type(privilege_list => xs$name_list('connect'),
principal_name => l_username,
principal_type => xs_acl.ptype_db));
commit;
end;
/12345678910111213141516
begin
apex_util.set_workspace(p_workspace => 'DEV_WS');
end;
/
declare
l_workspace_id apex_workspaces.workspace_id%type;
begin
select workspace_id
into l_workspace_id
from apex_workspaces
where workspace = 'DEV_WS';
apex_util.set_security_group_id(p_security_group_id => l_workspace_id);
end;
/12345678910
begin
apex_mail.send(
p_to => '[email protected]',
p_from => '[email protected]',
p_body => 'Plain text message body.' || utl_tcp.crlf,
p_subj => 'Plain text message subject.');
commit;
end;
/1234567891011121314151617181920
declare
l_body clob;
l_body_html clob;
begin
l_body := 'Please use a HTML mail client.';
l_body_html := '<html><head></head><body>' ||
'<p>HTML message body.</p>' ||
'</body></html>';
apex_mail.send(
p_to => '[email protected]',
p_from => '[email protected]',
p_body => l_body,
p_body_html => l_body_html,
p_subj => 'HTML message subject.');
commit;
end;
/1234567891011121314151617181920212223242526272829
declare
l_mail_id NUMBER;
l_blob blob;
l_clob clob;
begin
l_blob := UTL_RAW.cast_to_raw('This could be a document or image.');
l_clob := 'This could be any CLOB information';
l_mail_id := apex_mail.send(
p_to => '[email protected]',
p_from => '[email protected]',
p_body => 'Attachment message body.',
p_subj => 'Attachment message subject.');
apex_mail.add_attachment(
p_mail_id => l_mail_id,
p_attachment => l_blob,
p_filename => 'blob_attachment.binary',
p_mime_type => 'application/octet-stream');
apex_mail.add_attachment(
p_mail_id => l_mail_id,
p_attachment => l_clob,
p_filename => 'clob_attachment.txt',
p_mime_type => 'text/plain');
commit;
end;
/123456789101112
select count(*) from apex_mail_queue;
COUNT(*)
----------
0
SQL>
begin
apex_mail.push_queue;
end;
/Please to add comments
No comments yet. Be the first to comment!