Hi,
I have a PL/SQL package that writes to a file using utl_file, I also want to send an email with the file as an attachment.
mail_text_ varchar2(2000);
file_name_ VARCHAR2(32000);
output varchar2(32000);
attachment_text Clob;
file_t := utl_file.fopen('DATA_MIGRATION', 'IPIS' || to_char(sysdate,'YYYYMMDD') || '.CSV','R') ;
loop
begin
utl_file.get_line(file_t,output);
attachment_text := attachment_text||output||utl_tcp.crlf;
EXCEPTION
WHEN NO_DATA_FOUND THEN EXIT;
end;
END LOOP;
-- dbms_output.put_line(attachment_text);
UTL_FILE.FCLOSE(file_t);
mail_text_ := 'Inventory part in stock report for <b>'||trunc(Sysdate)||'.<br />
<br />
Regards,<br />
IFS<br />
<br />
';
ifsapp.command_sys.Mail(sender_ => ifsapp.fnd_session_api.Get_App_Owner,
from_ => 'O365.SMTP@xxxx.co.uk',
to_list_ => 'xyz@xyz.co.uk',
cc_list_ => Null,
bcc_list_ => 'xyz@xyz.co.uk',
subject_ => 'IPIS daily extract',
text_ => to_clob(mail_text_) ,
attach_ => to_clob(attachment_text) ,
rowkey_ => null,
mail_sender_ => null);
utl_file.fremove( 'DATA_MIGRATION', 'IPIS' || to_char(sysdate,'YYYYMMDD') || '.CSV' ) ;
When I run the code I am getting the following error message:

It looks as if there is an issue with the attachment but I cannot work out what the issue is, can anyone advise please ?
Thanks