How to send Email from Forms using Run_report_object and web.show_document
How to send Email from Forms using Run_report_object and web.show_document
Titleimage
Posted by Patrick Hamou on 2017:09:12 15:16:43
APPLIES TO:
Oracle Reports Developer - Version 9.0.4.0 to 11.1.1.6.0 [Release Oracle9i to 11g]
Oracle Forms - Version 9.0.4.0.19 to 11.1.1.6.0 [Release 9.0.4.0 to 11g]
Information in this document applies to any platform.
GOAL
How to send email from Forms using Run_Report_Object using a parameter list and web.show_document and using values from the Form that fill in Subject, To, From, CC and Bcc.
It is assumed that the Reports Server is already configured to use a mail server through its CONF file, e.g.:
<pluginParam name="mailServer">mail.oracle.com</pluginParam>
FIX
The instructions below create a simple Form that provide fields that can be used to send email.
The fields created are To, From, Subject, CC and Bcc.
1. Create a Form with control block and fields
eg.
Block name :email
field names: To, From, CC, BCC, Subject, reportserver
2. Create two buttons:
eg.
Send email via run_report_object
Send email via web.show_document.
Create report node in Form that contains a report see:
Note 207396.1 How to Run Reports From Forms 9i / 10g Using RUN_REPORT_OBJECT?:
Create triggers on buttons when-button-pressed
3. For button "Send email via run_report_object"
Add code
--This code send the report directly EMAIL"
declare
v_rep varchar2(1000):='a';
v_rep_status varchar2(1000):='a';
v_url varchar2(1000):='';
--v_rep_server varchar2(1000):='';
repid REPORT_OBJECT;
thelist paramlist;
begin
thelist := get_parameter_list('rep_paramlist');
if not id_null(thelist) then
destroy_parameter_list(thelist);
end if;
thelist := CREATE_PARAMETER_LIST('rep_paramlist');
ADD_PARAMETER(thelist, 'FROM',TEXT_PARAMETER, :email.from);
ADD_PARAMETER(thelist, 'BCC',TEXT_PARAMETER, :email.bcc);
ADD_PARAMETER(thelist, 'CC',TEXT_PARAMETER, :email.cc);
ADD_PARAMETER(thelist, 'SUBJECT',TEXT_PARAMETER, :email.subject);
repid := find_report_object('REPORT30');
set_report_object_property(repid,REPORT_SERVER,:email.repserver);
--v_rep_server := get_report_object_property(repid,report_server);
set_report_object_property(repid,REPORT_DESTYPE,MAIL);
set_report_object_property(repid,REPORT_DESFORMAT,'html');
set_report_object_property(repid,REPORT_DESNAME,:email.too);
v_rep:=run_report_object(repid,thelist);
end;
4. For Button "Send email via web.show_document"
Add code:
--This trigger calls the reports server directly without using run_report_object
declare
vc_url varchar2(1000):='a';
begin
vc_url:=('/reports/rwservlet?server='||:email.repserver||'&report=test.rdf&destype=mail&desformat=html&desname='||:email.too||'&from='||:email.from||'&subject='||:email.subject||'&cc='||:email.cc||'&bcc='||:email.bcc);
web.show_document(vc_url,'_blank');
end;
Posted by Patrick Hamou on 2017:09:12 15:16:43