Home » Developer & Programmer » Forms » Send Email with PDF attachment (Oracle 10g Forms,Database 10 R2)
Send Email with PDF attachment [message #330550] |
Mon, 30 June 2008 07:33 |
asadkhan_2
Messages: 36 Registered: January 2008
|
Member |
|
|
Customers are defined in a table with email addresses now i want this that when the report is called from a button then it sends mail automatically to the list of predefined customers with the pdf attachment of that opened report
can anyone help me in this regard
Thanks
|
|
|
|
Re: Send Email with PDF attachment [message #334793 is a reply to message #330550] |
Fri, 18 July 2008 00:53 |
vishal_kapadia
Messages: 4 Registered: July 2008 Location: Mumbai
|
Junior Member |
|
|
PROCEDURE PL_EMAIL_GENERATION_NEW IS
al_button Number := 0;
p_error_flg Varchar2(1) := 'N';
cnt number:=0;
prvposn number:= 0;
ret_posn number:=0;
e_addr varchar2(2000);
v_lastemail Number :=0;
X NUMBER;
smobj ole2.obj_type;
dbmobj ole2.obj_type;
docmobj ole2.obj_type;
rtiobj ole2.obj_type;
rtiobj1 ole2.obj_type;
rtiobj2 ole2.obj_type;
neoobj1 ole2.obj_type;
neoobj2 ole2.obj_type;
my_arglist ole2.list_type;
my_arglist1 ole2.list_type;
my_arglist2 ole2.list_type;
my_arglist3 ole2.list_type;
my_arglist4 ole2.list_type;
my_arglist5 ole2.list_type;
my_arglist6 ole2.list_type;
my_arglist7 ole2.list_type;
my_arglist15 ole2.list_type;
my_arglist16 ole2.list_type;
my_arglist17 ole2.list_type;
my_arglist18 ole2.list_type;
my_arglist19 ole2.list_type;
my_arglist20 ole2.list_type;
my_arglist21 ole2.list_type;
my_arglist22 ole2.list_type;
my_arglist23 ole2.list_type;
my_arglist24 ole2.list_type;
my_arglist25 ole2.list_type;
my_arglist91 ole2.list_type;
my_arglist92 ole2.list_type;
my_arglist93 ole2.list_type;
my_arglist94 ole2.list_type;
v_Noofrec Number;
err_code binary_integer;
err_text varchar2(2000);
p_to_address varchar2(2000);
p_subject varchar2(2000);
p_attachment_file_name varchar2(2000);
v_tradefilename varchar2(200);
p_file_number number := 1;
v_clnt_email varchar2(2000);
records_checked number := 0;
v_file_path varchar2(2000);
no_email_add_count number :=0;
v_mail_ref_num number :=0;
v_tm_cd varchar2(20);
v_user varchar2(200);
v_username varchar2(200);
cc_to_address varchar2(2000);
bcc_to_address varchar2(2000);
file_status char;
lv_body_text VARCHAR2(1000);
cccount NUMBER;
v_password Varchar2(100);
begin
-- lotus notes declaration session
smobj := ole2.create_obj('NOTES.NOTESSESSION');
my_arglist := ole2.create_arglist;
ole2.add_arg(my_arglist , '');
ole2.add_arg(my_arglist , '');
dbmobj := ole2.invoke_obj(smobj, 'GETDATABASE', my_arglist ) ;
ole2.invoke(dbmobj, 'OPENMAIL');
v_user:= OLE2.Get_Char_Property(smobj, 'EffectiveUserName');
--v_password:=OLE2.Get_Char_Property(smobj,'password');
--MESSAGE('pass '|| v_password); MESSAGE(' ');
x:= INSTR(v_user,'/');
x:= x- 4;
v_username := substr(v_user,4,x) ;
GO_BLOCK('EMAIL_LOG');
FIRST_RECORD;
LOOP -- Email_log block loop
:email_log.email_sent_x := 0;
:email_log.email_not_sent_x := 0;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
END LOOP; -- Email_log Block end loop
FIRST_RECORD;
Loop
-- Added for Checking the file
PL_FILE_CHECK(:filename,file_status);
IF file_status = 'N' THEN
p_error_flg := 'Y';
:email_log.email_flg := 'F';
END IF;
-- End Checking
if :RESEND_YN = 'Y' then
synchronize;
records_checked := records_checked +1;
--v_clnt_email := :to_id;
v_clnt_email := :to_id;
cc_to_address := :cc_id||:bcc_id;
bcc_to_address:= :bcc_id;
v_tm_cd := :bo_id;
cnt := 1;
prvposn := 1;
--for cnt in 1..12 loop
/*
if cnt=1 then
ret_posn := instr(v_clnt_email||',',',', prvposn);
else
ret_posn := instr(v_clnt_email,',', prvposn);
end if;
if ret_posn = 0 then
exit;
end if;
e_addr := LTRIM(RTRIM(Substr(v_clnt_email, prvposn, (ret_posn - prvposn))));
prvposn := ret_posn + 1;
*/
e_addr := LTRIM(RTRIM(v_clnt_email));
begin -- send through notes
set_application_property(cursor_style,'busy');
docmobj := ole2.invoke_obj(dbmobj, 'CREATEDOCUMENT');
p_to_address := e_addr;
my_arglist1 := ole2.create_arglist;
ole2.add_arg(my_arglist1, 'SENDTO');
ole2.add_arg(my_arglist1,p_to_address );
ole2.invoke(docmobj,'REPLACEITEMVALUE',my_arglist1);
If cc_to_address is not null AND cnt = 1 then
my_arglist24 := ole2.create_arglist;
ole2.add_arg(my_arglist24 , 'COPYTO');
ole2.add_arg(my_arglist24 , ltrim(rtrim(cc_to_address)));
ole2.invoke(docmobj,'REPLACEITEMVALUE',my_arglist24);
End if;
ole2.Set_Property(docmobj, 'SaveMessageOnSend', TRUE);
ole2.Set_Property(docmobj, 'DeliveryReport', 'N');
p_subject := 'Transactions Report for the period '||:bl_main.p_from_date ||' to '||:bl_main.p_to_date;
my_arglist2 := ole2.create_arglist;
ole2.add_arg(my_arglist2 , 'SUBJECT');
ole2.add_arg(my_arglist2 , p_subject );
ole2.invoke(docmobj,'REPLACEITEMVALUE',my_arglist2);
my_arglist5 := ole2.create_arglist;
ole2.add_arg(my_arglist5 , 'BODY');
rtiobj := ole2.invoke_obj(docmobj , 'CREATERICHTEXTITEM', my_arglist5);
my_arglist17 := ole2.create_arglist;
ole2.add_arg(my_arglist17 ,2);
rtiobj2 := ole2.invoke_obj(RTIOBJ,'Addnewline', my_arglist17);
my_arglist18 := ole2.create_arglist;
ole2.add_arg(my_arglist18 , '1454');
ole2.add_arg(my_arglist18 , '');
if :bo_id is not null then
lv_body_text := lv_body_text ||'Please find Statement of Transactions for '||to_char(:BL_MAIN.P_TO_DATE,'DD-MM-RRRR')||' .';
lv_body_text := lv_body_text ||'For any clarifications, kindly contact your respective branch.';
ole2.add_arg(my_arglist18, lv_body_text);
end if;
rtiobj1 := ole2.invoke_obj(RTIOBJ,'APPENDTEXT',my_arglist18);
my_arglist19 := ole2.create_arglist;
ole2.add_arg(my_arglist19 ,2);
rtiobj2 := ole2.invoke_obj(RTIOBJ,'Addnewline', my_arglist19);
my_arglist6 := ole2.create_arglist;
ole2.add_arg(my_arglist6 , '1454');
ole2.add_arg(my_arglist6 , '');
p_attachment_file_name := ltrim(rtrim(:filename));
ole2.add_arg(my_arglist6 ,p_attachment_file_name);
neoobj1 := ole2.invoke_obj(rtiobj , 'EMBEDOBJECT',my_arglist6);
-- End if;
my_arglist20 := ole2.create_arglist;
ole2.add_arg(my_arglist20 ,2);
rtiobj2 := ole2.invoke_obj(RTIOBJ,'Addnewline', my_arglist20);
my_arglist4 := ole2.create_arglist;
ole2.add_arg(my_arglist4 , '0');
ole2.invoke(docmobj,'SEND',my_arglist4);
-- destroy session
ole2.destroy_arglist ( my_arglist1);
ole2.destroy_arglist ( my_arglist2);
ole2.destroy_arglist ( my_arglist3);
ole2.destroy_arglist ( my_arglist4);
ole2.destroy_arglist ( my_arglist5);
ole2.destroy_arglist ( my_arglist24);
ole2.destroy_arglist ( my_arglist17);
ole2.destroy_arglist ( my_arglist18);
ole2.destroy_arglist ( my_arglist19);
ole2.destroy_arglist ( my_arglist20);
ole2.destroy_arglist ( my_arglist6);
lv_body_text := null;
ole2.release_obj(rtiobj);
ole2.release_obj(docmobj);
SET_APPLICATION_PROPERTY(CURSOR_STYLE,'DEFAULT');
exception
when ole2.ole_error then
err_code := ole2.last_exception();
message('Notes Error . Contact Support');
message(' ',no_acknowledge);
end;
--end loop; ---
end if;
ole2.release_obj(rtiobj);
ole2.release_obj(docmobj);
SET_APPLICATION_PROPERTY(CURSOR_STYLE,'DEFAULT');
exception
when ole2.ole_error then
err_code := ole2.last_exception();
message('Notes Error . Contact Support');message(' ',no_acknowledge);
end;
end loop; ---
if :system.last_record = 'TRUE' then
exit;
else
next_record;
end if;
End loop;
-- Else
-- pl_messagebox('al_error','You are not authorised to send Mail .....',
-- 'Error',al_button,'Y');
-- End If;
--end if file creation session
-- release objects
ole2.destroy_arglist ( my_arglist);
ole2.release_obj(smobj);
ole2.release_obj(dbmobj);
message('Reports E-Mailed');
message(' ',no_acknowledge);
clear_block(no_validate);
--GO_item('BU_QRY');
--Execute_Trigger('WHEN-BUTTON-PRESSED');
end ;
|
|
|
Goto Forum:
Current Time: Sat Nov 09 16:06:26 CST 2024
|