APEX_MAIL_ATTACHMENTS View

You can use the APEX_MAIL_ATTACHMENTS view in conjunction with the existing APEX_MAIL_QUEUE to access email attachments associated with email messages in the Oracle Application Express mail queue.

Example

The following example demonstrates how to access files stored in APEX_APPLICATION_FILES and add to an e-mail message.

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;
/