Home » SQL & PL/SQL » SQL & PL/SQL » Sending a Password protected PDF using utl_smtp
Sending a Password protected PDF using utl_smtp [message #658373] Mon, 12 December 2016 02:35 Go to next message
dineshkumar18
Messages: 28
Registered: September 2016
Junior Member
Dear AM using UTL_SMTP for attaching a PDF file but now i do have password protected PDF file and am not been able to attach the password protected file:



declare
        l_clob clob;
        vInhandle_read utl_file.file_type;
        vNewLine long;
    BEGIN
        vInHandle_read := utl_file.fopen('STMT_DIR', '4010367765001.pdf', 'R');
        LOOP
            begin
                utl_file.get_line(vInHandle_read,vNewLine);
           exception
           when no_data_found
           then
              EXIT;
          end;
          l_clob:=l_clob|| chr(10) || vnewline;
       end loop;
       utl_file.fclose(vInHandle_read);
       dbms_output.put_line( 'the clob is ' || length(l_clob) || ' bytes' );
   exception
   when others
   then
       if (utl_file.is_open(vInHandle_read))
       then
           utl_file.fclose(vInHandle_read);
       end if;
       RAISE;
   END;
   

4010367765001.pdf is a password protected pdf.


Attached the error message which am getting.

But am able to get the output for normal PDF

Kindly advise

/forum/fa/13354/0/


[mod-edit: image inserted into message body by bb]
  • Attachment: test.jpg
    (Size: 32.53KB, Downloaded 1941 times)

[Updated on: Mon, 12 December 2016 03:20] by Moderator

Report message to a moderator

Re: Sending a Password protected PDF using utl_smtp [message #658375 is a reply to message #658373] Mon, 12 December 2016 03:18 Go to previous messageGo to next message
dineshkumar18
Messages: 28
Registered: September 2016
Junior Member
Any update experts ???
Re: Sending a Password protected PDF using utl_smtp [message #658378 is a reply to message #658375] Mon, 12 December 2016 06:12 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

1/ You did not post your Oracle nor your OS, if these are fields you have to enter when creating a topic this is not for nothing and this has already been told to you
2/ did you do what the action part tells? If so prove it, posting the value and permissions of the directory and file.
3/ PDF is a binary file and so get_line is NOT the correct procedure.

Re: Sending a Password protected PDF using utl_smtp [message #658384 is a reply to message #658378] Mon, 12 December 2016 06:46 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
The only way to send a binary file via an SMTP email is to convert it to plain text using something like UUENCODE or MIME encoding. There are a lots of links on the internet that will show you how to do that
Re: Sending a Password protected PDF using utl_smtp [message #658418 is a reply to message #658375] Tue, 13 December 2016 06:57 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
dineshkumar18 wrote on Mon, 12 December 2016 03:18
Any update experts ???
=================================

Patience, Grasshopper

You posted this follow-up a mere 43 minutes after your previous post.

This forum is not a chat line, and it is not paid support.

Furthermore, it is a global forum. The person with the information you seek may very well live 20 time zones away from you and was going to bed just as you posted. He will not even see your post for several more hours.

Your original post went up in the middle of the night for half the world.


Re: Sending a Password protected PDF using utl_smtp [message #658421 is a reply to message #658418] Tue, 13 December 2016 07:41 Go to previous messageGo to next message
dineshkumar18
Messages: 28
Registered: September 2016
Junior Member
Thank You Tortise Razz

I have resolved the issue and you cam after a day to post this Message ??

Anyways thank you very much
Re: Sending a Password protected PDF using utl_smtp [message #658422 is a reply to message #658373] Tue, 13 December 2016 07:55 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3269
Registered: January 2010
Location: Connecticut, USA
Senior Member
Your code is wrong to begin with. It can have problems regardless if PDF is password protected or not. PDF is binary, not text file. So why are you trying to read it into CLOB? Use BLOB instead. Opening PDF using UTL_FILE with R format implies text file with lines <= 1024 (including EOL characters). UTL_FILE will fail if EOL is not found within next 1024 bytes. Mode RB is used to read binary files via UTL_FILE. But why are you using UTL_FILE to begin with? Use BFILENAME.

SY.
Re: Sending a Password protected PDF using utl_smtp [message #658423 is a reply to message #658422] Tue, 13 December 2016 08:09 Go to previous messageGo to next message
dineshkumar18
Messages: 28
Registered: September 2016
Junior Member
Thanks Solomon.

I have implemented it with BLOB and it is working fine.

Thanks for the advise Smile
Re: Sending a Password protected PDF using utl_smtp [message #658424 is a reply to message #658421] Tue, 13 December 2016 08:09 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
dineshkumar18 wrote on Tue, 13 December 2016 14:41
...
I have resolved the issue and you cam after a day to post this Message ??
...
And you didn't tell us how.
Do it now, post the correct code.

Previous Topic: Help in Listagg Query???
Next Topic: Comparing CAST (multiset) with Bulk Collect
Goto Forum:
  


Current Time: Thu Mar 28 11:28:41 CDT 2024