Skip to main content

APEX : Send email with attachment

I have found a working solution for sending email with attachment using APEX application. But first, few items have to take note :-
  1. User can insert any attachment into the form
  2. The attachment will be save into my own table within the Oracle database.
User can insert any attachment

This will be require an item named 'File Browse...'. Simply add the item into the page. I assume at this point, you already know how to it. Lets name it as [P1_ATTACHMENT]

Take a look at the [Settings] tab when u edit this item page. The storage type setting can be either two : 1.Table WWV_FLOW_FILES and 2.BLOB column specified in Item Source attribute

I will choose option No.1. Why I did not choose option No.2? As I had mentioned that the attachment will be save into my own table?

I am not expert, perhaps you can correct me if I am wrong, but I think that insert a attachment files into table will require some additional coding when we want to execute it in APEX environment.

One more reason is, I already has define one table to fetch row in the [Processes] in [After Header] section. So by adding another one more table (attachment table) it will make APEX get confused. Anyway, I have tried it. It does not work.

The attachment will be save into my own table within the Oracle database.

Next step is to save the file attachment to be save in my own attachment table. Lets name my table as ATTACHMENT_FILES. 
CREATE TABLE ATTACHMENT_FILES
(
  ID                 NUMBER,
  BLOB_CONTENT       BLOB,
  MIMETYPE           VARCHAR2(255 BYTE),
  FILENAME           VARCHAR2(255 BYTE),
  LAST_UPDATE        DATE,
  CHARSET            VARCHAR2(128 BYTE),
  UPLOADED_BY        VARCHAR2(10 BYTE),
  DOC_SIZE           NUMBER
)
Since I already have my table ready, I will now need to create one process to copy the file from WWV_FLOW_FILES into ATTACHMENT_FILES.

This process must be create at point [Processing > Processes] on [Page Processing]
  1. Right click on [Processes] > Create
  2. Select [PL/SQL] and Next
  3. Give a name to identify the procesess and click Next (lets name it as 'CopyFile')
  4. On the [Enter PL/SQL Page Process], paste below code;
begin
insert into ATTACHMENT_FILES( id, blob_content, mimetype, filename, last_update, doc_size )
select :P1_YOUR_ID, blob_content, mime_type, filename, created_on, doc_size from  wwv_flow_files where  name = :P1_ATTACHMENT;
delete from wwv_flow_files where name = :P1_ATTACHMENT;
end;
So by now, you got the idea already right? First, we let the attachment to be saved into WWV_FLOW_FILES. Then we copied it over to our own table and delete the original data from WWV_FLOW_FILES to avoid consume space and storage.

To avoid any complex coding in PL/SQL, I believe this method is faster. It depends on your needs.

Hurmm..I will talk about sending email as Part 2 later on.

Update : This is the Part 2.

Comments

  1. Today Microsoft Office has become the essential element for personal as well as professional use.
    www.office.com/setup
    office.com/setup

    ReplyDelete

Post a Comment

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…

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…

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.