sql - 我想使用 oracle apex 将我的电子邮件日志保存到我的个人表中
问题描述
我正在使用 apex_mail.send() 顶点邮件程序,现在我的目标是维护它的日志到另一个表。每当从 apex_mail.send() 程序发送电子邮件时,它都会将我的表中的每个条目都保存为日志。
DECLARE
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 ||'<p>Thank you for your interest in the <strong>APEX_MAIL</strong> package.</p>'||utl_tcp.crlf;
l_body_html := l_body_html ||' Sincerely,<br />'||utl_tcp.crlf;
l_body_html := l_body_html ||' <span class="sig">The APEX Dev Team</span><br />'||utl_tcp.crlf;
apex_mail.send(
p_to => 'some_user@somewhere.com', -- change to your email address
p_from => 'some_sender@somewhere.com', -- change to a real senders email address
p_body => l_body,
p_body_html => l_body_html,
p_subj => 'APEX_MAIL Package - HTML formatted message');
END;
解决方案
为确保您记录对 的每次调用apex_mail.send
,请创建一个记录调用的包装程序(或包),并且仅在发送电子邮件时使用您的包装程序。
例如:
create or replace package my_mail as
procedure send( ... );
...
end;
/
create or replace package body my_mail as
procedure send( ... ) as
begin
insert into log_table (column list) values (parameter value list);
...
<additional custom code>
...
apex_mail.send( ... );
end;
...
end;
/
作为使用您自己的包装器的一个附带好处,您可以添加额外的功能,例如在开发或 UAT 环境中自动将收件人地址重写为测试地址,这样您就不会意外地向真实用户发送测试数据垃圾邮件。
推荐阅读
- c# - TcpListener 在 UWP 应用程序上不起作用
- r - 为什么 R 中的 mtcars 数据集中没有汽车名称的列名?
- haskell - Haskell、Ocaml、Javascript 中的语句与表达式
- angularjs - AngularJS ui-router - 生成
返回当前网址 - java - box2d 在 libgdx 上精灵的不同位置
- android - Android App崩溃,无法解决问题
- android - 导航架构组件 - 对话框片段
- google-apps-script - 如何在谷歌脚本中复制和粘贴包含裁剪信息的图像
- html - background-color 属性在 Safari 上不起作用
- bash - 使用 sed 删除行,如果它包含 1 个模式,则使用下面的行,但不包含另一个