--------------------------------------------------------------------------------------------
-- Apex Activity Logs
--------------------------------------------------------------------------------------------
select * From apex_040100.WWV_FLOW_ACTIVITY_LOG1$ order by TIME_STAMP desc;
select * From apex_040100.WWV_FLOW_ACTIVITY_LOG2$ order by TIME_STAMP desc;


---------------
-- Hourly Hits
---------------
select TRUNC(al.time_stamp,'HH24'), count(1) 
From (select * from apex_040100.WWV_FLOW_ACTIVITY_LOG1$ 
      union all
      select * from apex_040100.WWV_FLOW_ACTIVITY_LOG2$
      )al
group by TRUNC(al.time_stamp,'HH24')
order by TRUNC(al.time_stamp,'HH24') desc;



-----------------------------------
-- Apex Mail test
-----------------------------------
declare 
   l_workspace_id apex_workspaces.workspace_id%type; 
begin
    SELECT app.workspace_id
     into  l_workspace_id
           FROM apex_applications app
           WHERE app.application_id = 508;
    wwv_flow_api.set_security_group_id(l_workspace_id);

    apex_mail.send(p_to    => 'vishal@vishalgupta.com (Vishal Gupta),email@domain.com (Firstname Surname)',
               p_from      => 'from@domain.com',
               p_body      => 'Testing',
               p_body_html => '<html><b>This is testing</b></html>',
               p_subj      => 'Testing Email',
         			   p_cc        => 'cc@domain.com',
               p_bcc       => null);
    APEX_MAIL.PUSH_QUEUE;
end;
/

-----------------------------------
-- Apex Mail Log
-----------------------------------
SELECT * from APEX_040100.WWV_FLOW_MAIL_LOG ORDER BY last_updated_on desc;
SELECT * from APEX_040100.WWV_FLOW_MAIL_QUEUE ORDER BY last_updated_on desc;
SELECT * from APEX_040100.WWV_FLOW_MAIL_ATTACHMENTS ORDER BY last_updated_on desc;



SELECT last_updated_on, last_updated_by, mail_from, mail_to, mail_bcc, mail_cc, mail_subj from APEX_040100.WWV_FLOW_MAIL_LOG ORDER BY LAST_UPDATED_ON DESC;



--------------------------------------------------------------------------------------------
-- Apex email settings
--------------------------------------------------------------------------------------------

- Login to Apex INTERNAL workspace using admin user
- Manage Instances
- Instance settings
- Click on Email tab
     SMTP Host Address 	
     SMTP Host Port 	
     SMTP Authentication Username 	
     SMTP Authentication Password 	
     Use SSL/TLS 	
     Administration Email Address 	
     Notification Email Address 	
     Maximum Emails per Workspace 	



