我知道可以使用带有以下代码的附件的apex邮件通过oracle apex发送邮件 -
DECLARE
l_id NUMBER;
BEGIN
l_id := APEX_MAIL.SEND(
p_to => 'fred@flintstone.com',
p_from => 'barney@rubble.com',
p_subj => 'APEX_MAIL with attachment',
p_body => 'Please review the attachment.',
p_body_html => '<b>Please</b> review the attachment');
FOR c1 IN (SELECT filename, blob_content, mime_type
FROM APEX_APPLICATION_FILES
WHERE ID IN (123,456)) LOOP
APEX_MAIL.ADD_ATTACHMENT(
p_mail_id => l_id,
p_attachment => c1.blob_content,
p_filename => c1.filename,
p_mime_type => c1.mime_type);
END LOOP;
COMMIT;
END;
/
但是,我想将远程文件附加到通过oracle apex而不是blob内容发送的邮件
p_attachment => c1.blob_content,
即,我想在邮件中附加一个文件,例如D:\sample.pdf
作为附件。
我想知道是否有可能,如果可能的话怎么样?
答案 0 :(得分:0)
我从帖子here
中得到了答案我使用以下方法发送邮件
DECLARE
l_id NUMBER;
l_bfile BFILE;
l_blob BLOB;
BEGIN
DBMS_LOB.createtemporary(l_blob, TRUE); -- Initialize the BLOB.
l_bfile := BFILENAME('TEST', 'test.pdf');
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
l_id := APEX_MAIL.SEND(
p_to => 'account@host.com',
p_from => 'account@host.com',
p_subj => 'APEX_MAIL with attachment',
p_body => 'Please review the attachment.',
p_body_html => '<b>Please</b> review the attachment');
APEX_MAIL.ADD_ATTACHMENT(
p_mail_id => l_id,
p_attachment => l_blob,
p_filename => 'test.pdf',
p_mime_type => 'application/pdf');
DBMS_LOB.fileclose(l_bfile);
DBMS_LOB.freetemporary(l_blob);
COMMIT;
END;