Skip to main content

APEX : Send email with attachment (Part 2)

Please refer to my previous post related to this, here.

Moving forward, by now you should already completed doing these 2 things:
  1. User can insert any attachment into the form
  2. The attachment will be save into my own table within the Oracle database.
So now, the next step is to configure APEX to sent-out email together with the attachment.

The email process must be create at point [Processing > Processes] on [Page Processing] , right after the 'CopyFile' process (refer to my previous post)
  1. Right click on [Processes] > Create
  2. Select [PL/SQL] and Next
  3. Give a name to identify the procesess and click Next
  4. On the [Enter PL/SQL Page Process], paste below code;
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 attachment_files
                WHERE ID = :P1_YOUR_ID ) 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;
END;
BEGIN
wwv_flow_mail.push_queue(
   P_SMTP_HOSTNAME => 'localhost',
   P_SMTP_PORTNO => '25'
);
END;
Please see the code and change whenever suit with your table name and page item. For example code below:
FOR c1 IN (SELECT filename, blob_content, mime_type
                 FROM attachment_files
                WHERE ID = :P1_YOUR_ID ) loop
The [attachment_files] comes from my table which I have created previously in so called Part 1.

You can have multiple 'File Browse...'. You may also need to change the PL/SQL code if have more [File Browse]. Do comment below if you still need help.

I will try my best to help. :)


Comments

Popular posts from this blog

Problem open TOAD after install : You have no Oracle Client installed.

I encounter a problem with my TOAD for Oracle just now. It mentioned You have no Oracle Client installed .Wondering what is the problem and below was the screenshot of it.





The solution is very simple. And I also found the root cause of it.


Root cause: Toad do not support Oracle Client for 64 bit. As simple as that


Solution : Install Oracle Client 32 bit. You may install another copy of Oracle client, or you may remove the 64 bit which you previously installed.


To be particular, my machine was a Windows 64 bit platform, and I directly apply Resolution 2 as below.


Below are the statement from the Quest Software support site.
For more detail from the site: https://support.quest.com/Search/SolutionDetail.aspx?id=SOL39689
Cause
- There is no Oracle client installed on the machine or the client installed is 64-bit. Toad does not support a 64-bit Oracle client.
- Environment Variable Path is missing.


Solution for 'You have no Oracle Client installed' :RESOLUTION 1:
Check to make sure there is a…

Interesting Google Chrome Web Tools to capture a whole web page

For most of internet user, getting a snapshot of a web, or a picture from the web, is very common and sometimes it is difficult to mange.

But with Google Screen Capture for Google Chrome,to save a screenshot of a page is very interesting yet very easy to use. The best part of it, which I personally think very important and most interesting, this tool manage to capture the whole webpage from top to bottom of page. I love it so much!

Below are the simple step to install.

1. You will need a Google Chrome installed. If you do not have it, grab it here.
2. Open your chrome and click on the [Web Store] button located at right bottom of the Chrome page.
3. Search for [Google]
4. Scroll down and look for Google Screen Capture, and install it.

This is great tool, very much love it. Enjoy.

APEX - How to grab value from Shuttle and save it into database

So you are using Oracle APEX shuttle in your form and will give the ability to user to select multiple value from the list. The next challenge is to store the selected values into the Oracle database.


Oracle APEX Shuttle : How to do it? In this post, I will talk about storing the multiple values into Oracle database in a way of storing the value one by one. Meaning that, if there are 4 active selection, the operation will be storing or insert the 4 value into Oracle table each row. So there will be 4 insert operation will be executed.

Please check below code:
declare
    tab apex_application_global.vc_arr2;
begin
    tab := apex_util.string_to_table (:PX_YOUR_ITEM);
    for i in 1..tab.count loop
        insert into YOUR_TABLE (YOUR_COLUMN_NAME, YOUR_SHUTTLE_COLUMN_NAME)
        values
('My List', tab(i) );
    end loop;
end; Please note that :PX_YOUR_ITEM is referring to your Shuttle Item name.

Where should I put those code?

1.Page Processing > Processing > Process, rig…