How to mail pdf file from oracle database 11g

Hi,
Using following code to send pdf file from oracle database.
DECLARE
v_From VARCHAR2(80) := '[email protected]';
v_Recipient VARCHAR2(80) := '[email protected]';
v_Subject VARCHAR2(80) := 'test subject';
v_Mail_Host VARCHAR2(30) := '116.214.31.249';
v_Mail_Conn sys.utl_smtp.Connection;
crlf VARCHAR2(2) := chr(13)||chr(10);
BEGIN
v_Mail_Conn := sys.utl_smtp.Open_Connection(v_Mail_Host, 26);
sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
sys.utl_smtp.Mail(v_Mail_Conn, v_From);
sys.utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
sys.utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
'From: ' || v_From || crlf ||
'Subject: '|| v_Subject || crlf ||
'To: ' || v_Recipient || crlf ||
'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
'Content-Type: multipart/mixed;'|| crlf ||
' boundary="-----SECBOUND"'|| crlf ||
crlf ||
'-------SECBOUND'|| crlf ||
'Content-Type: text/plain;'|| crlf ||
'Content-Transfer_Encoding: 7bit'|| crlf ||
crlf ||
'some message text'|| crlf ||     -- Message body
'more message text'|| crlf ||
crlf ||
'-------SECBOUND'|| crlf ||
'Content-Type: file;'|| crlf ||
' name="D:\mail\pdfSample.pdf"'|| crlf ||
'Content-Transfer_Encoding: 8bit'|| crlf ||
'Content-Disposition: attachment;'|| crlf ||
' filename="D:\mail\pdfSample.pdf"'|| crlf ||
crlf ||
'CSV,file,attachement'|| crlf ||     -- Content of attachment
crlf ||
'-------SECBOUND--'               -- End MIME mail
sys.utl_smtp.Quit(v_mail_conn);
EXCEPTION
WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
END;
Above code executed successfully and mail is send to recipient but file is corrupted.
I think it doesn't pick file from specified location, attachment name is appearing like this 'D:mailpdfsample.pdf
Oracle Database : 11g R2
O.S : windows 7 Professional
Thanks in Advance

parapr wrote:
sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);The above violates RFC 5321 section 4.1.1.1
'-------SECBOUND'|| crlf ||
'Content-Type: file;'|| crlf ||
' name="D:\mail\pdfSample.pdf"'|| crlf ||
'Content-Transfer_Encoding: 8bit'|| crlf ||
'Content-Disposition: attachment;'|| crlf ||
' filename="D:\mail\pdfSample.pdf"'|| crlf ||Invalid Mime header above. Filename are logical. Not physical. Loose the drive and directory names. The filename is there to name the Mime body's content.
crlf ||
'CSV,file,attachement'|| crlf ||     -- Content of attachmentHow is the above PDF content? This is a string containing the text CSV,file,attachement. Which means when this is what is saved as a PDF file by the mail reader.
EXCEPTION
WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
END;Silly. Why change meaningful exceptions into a generic meaningless exception?? That does not make any sense.

Similar Messages

  • How to access a PDF file from Oracle DATABASE SERVER

    Hi
    I have some pdf files in "\home2\docs" directory in Oracle database server 10g. (OS is Linux) I want to access those pdf files from my client system through Oracle Forms. How is it possible?
    Please Help!!!! It is very urgent !!!
    Expecting fast response!!!!!
    Bye

    hi
    Thank u for ur response.
    Initially i tried to access pdf file from database server. I didn't get any solution for that. So I copied all my pdf files to Application server which is in Linux environment at "/home2/docs" directory.
    I gave the following command for accessing the pdf files kept in Lnux Application Server from Oracle 10g forms in a button press trigger.
    web.show_document('http://192.168.1.53:7779/home2/docs/test.pdf');
    It says "page cannot be found"
    So I copied one of the pdf file named "test.pdf" to "/oracle/oas10g/IasHome/forms90/java" in Linux Application Server . Then the following command
    web.show_document('http://192.168.1.53:7779/forms90/java/test.pdf');
    has opened the the pdf file in browser.
    192.168.1.53 is my Linux Application Server IP. and 7779 is the port.
    Actually we have lacs of pdf files. So i cannot keep all the pdf files in "/oracle/oas10g/IasHome/forms90/java" directory in Linux Application Server. And also all the pdf files not in the same directory , "/home2/docs" some of the pdf files r in the subdirectories of "/home2/docs/" like /home2/docs/sub1, /home2/docs/sub2, /home2/docs/sub3 etc.
    Then how to configure my "/oracle/oas10g/IasHome/forms90/server/forms90.conf" file for retrieving pdf files from "/home2/docs/" and its subdirectories. Is Anything other than this, required for solving my problems.
    Now My PDF files r in LINUX APPLICATION SERVER not in database server.
    Please help!! It is VERY URGENT!!!

  • How to generate XML file from oracle database query result

    Hi dudes,
    as stated on the subject, can anyone suggests me how can i achieve the task stated above??
    Here is a brief description of my problem:
    I need to create a XML file once i query from the oracle database, and the query result returned from the database will be stored in XML file.
    I'd searched around the JAXB, DOM, SAXP and the like basic concepts, but i still don't know how to start??
    Any suggestions ???

    Read this:
    http://www.cafeconleche.org/books/xmljava/chapters/ch08s05.html
    You might have to read more of the book to understand that chapter.

  • How to load PDF files into oracle database and display them in APEX

    Hi All,
    We have a requirement for loading the Loading PDF files (lots of PDf files) to the oracle database and then display the PDF files in the Oracel APEX report.
    So that User can view the PDF files. Our current APEX verison is 3.2..
    Please let me know how to implement it and where to find the sample application!
    Thanks in advanced!
    Jane

    Thanks Tony for your quick response!
    We need to load a lot of PDfs (history + current).
    I have a questions about the SQL loader. I am trying to insert a pdf file into a table by following the oracle loading sample:
    http://download.oracle.com/docs/cd/B10501_01/text.920/a96518/aload.htm
    Example Data File: loader2.dat
    This file contains the data to be loaded into each row of the table, articles_formatted.
    Each line contains a comma separated list of the fields to be loaded in articles_formatted. The last field of every line names the file to be loaded in to the text column:
    Ben Kanobi, plaintext,Kawasaki news article,../sample_docs/kawasaki.txt,
    But i don't know to where should I put my pdf file on the server.
    for example:
    ,../sample_docs/kawasaki.txt,
    Where is the file 'kawasaki.txt'??
    I try my local path, it didn't work. like c:\temp.
    then I loaded teh PDf file into our server(/findev20/olmtest/orafin/11.5.7/olmtestcomn/temp) , and In my data file. I put the path
    1, pdf_emp1,../findev20/olmtest/orafin/11.5.7/olmtestcomn/temp
    but I got the error: the system can not find the file specified.
    Where should I put the PDf files on the server and how to specify the path in the data file?
    Thanks!
    Jane

  • How to call pdf files from oracle forms

    I have a pdf file in the server , I need to call this and open when a button is pressed in the oracle forms.
    Please let me know how to do this.
    Thanks,
    Previn

    Frank,
    I have oracle applications and I want to open a pdf file located in the server from a button in oracle applications.
    Previn,
    you don't mention the Forms release you are running.
    If you are running Forms on the web, you can use
    web.show_document() to load files from the Web if
    they are accessible via HTTP.
    Frank

  • How to export an XML file from oracle database?

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AM

    user3523292 wrote:
    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AMThis is a forum of volunteers. There is no "urgent" here. Nevertheless, a google search of 'xml oracle export' quickly lead me to this Oracle site:
    otn.oracle.com/sample_code/tech/xml/index.html
    I also see lots of hits when I search the documentation library at tahiti.oracle.com for 'xml'. This one in particular may be what you are looking for:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#ADXDK070

  • How to generate .SQL format file from oracle database?

    How to generate .SQL format file from oracle database?
    I have a database of Oracle 8.1.6,now want to generate script file (including table structure,index,etc.) from it,What should I do?
    Thanks.

    Your question pertains to the Database Export/Import. This forum exclusively focusses on the export/import utilities that come along with "Oracle Portal" which is a web-based tool. Could you please post your question under the RDBMS export/import or migration forum.

  • Store PDF File in Oracle database 10g

    Hi all,
    I want to store PDF File in Oracle database 10g,
    and then I want to access the pdf file using Oracle Developer 6i
    can anyone tell me how to do this,
    thanks in advance.

    This question has already been posted a lot of times.....
    See the following:
    http://forums.oracle.com/forums/search.jspa?threadID=&q=pdf+file&objID=f82&dateRange=lastyear&userID=&numResults=15
    Greetings,
    Sim

  • Export an XML file from oracle database

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database? is it possible..?
    thanks in advance,
    Bala. is it possible?
    Edited by: user3523292 on Nov 14, 2008 5:45 AM

    Here's the quick and dirty method using SQL*Plus...
    SQL> select * from emp where deptno = 10;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    SQL> set markup html on
    SQL> select * from emp where deptno = 10;
    <br>
    <p>
    <table border='1' width='90%' align='center' summary='Script output'>
    <tr>
    <th scope="col">
    EMPNO
    </th>
    <th scope="col">
    ENAME
    </th>
    <th scope="col">
    JOB
    </th>
    <th scope="col">
    MGR
    </th>
    <th scope="col">
    HIREDATE
    </th>
    <th scope="col">
    SAL
    </th>
    <th scope="col">
    COMM
    </th>
    <th scope="col">
    DEPTNO
    </th>
    </tr>
    <tr>
    <td align="right">
          7782
    </td>
    <td>
    CLARK
    </td>
    <td>
    MANAGER
    </td>
    <td align="right">
          7839
    </td>
    <td>
    09-JUN-81
    </td>
    <td align="right">
          2450
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    <tr>
    <td align="right">
          7839
    </td>
    <td>
    KING
    </td>
    <td>
    PRESIDENT
    </td>
    <td align="right">
    </td>
    <td>
    17-NOV-81
    </td>
    <td align="right">
          5000
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    <tr>
    <td align="right">
          7934
    </td>
    <td>
    MILLER
    </td>
    <td>
    CLERK
    </td>
    <td align="right">
          7782
    </td>
    <td>
    23-JAN-82
    </td>
    <td align="right">
          1300
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    </table>
    <p>
    SQL&gt;which you can spool to a file.

  • Pulling a PDF file from the database

    How would I display a pdf file from the database, or should I convert it to an image and if so how do I convert it into an image?

    Hi Phil_Kenya,
    Some samples here:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/db1556be-0f71-41cb-92de-b95f1e1ca3a3/how-can-i-load-a-pdf-file-in-my-database-filemdf-in-aspnet-web-project?forum=csharpgeneral
    http://stackoverflow.com/questions/7747796/displaying-pdf-files-in-a-web-page-from-a-sql-database-directly-without-needing
    I suggest you post this issue to the language development forum like above case, I think you would get more dedicated support.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to upload pdf file from windows cell phone?

    How to upload pdf file from windows cell phone?

    You can do this in steps.. First use the built in method for uploading a file into the flows files object, Next you would copy the file out to an Oracle built directory on your UNIX box using utl_file.put_raw..
    Here is a link to show you how to upload files in an APEX application [http://download.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm]
    And here is a link to show you how to use utl_file.put_raw.. [http://psoug.org/reference/utl_file.html], item is towards the bottom of the screen..
    Thank you,
    Tony Miller
    Webster, TX

  • Generated pdf file from oracle reports show bad characters

    Hello all,
    Iam fighting with a problem with generated pdf file from oracle reports which show some bad characters. I was searching for some information but it didnt help...
    I have Oracle Database 11g R2 (or 10g R2) on Oracle Linux or Windows, Oracle forms and reports 6i (i know that is very old and not supported with 11gr2 but we are in this scenario).
    NLS parameters are set like this
    server:
    NLS_CHARACTERSET EE8MSWIN1250
    NLS_TERRITORY AMERICA
    NLS_LANGUAGE AMERICAN
    client:
    NLS_CHARACTERSET EE8MSWIN1250
    NLS_TERRITORY SLOVAK
    NLS_LANGUAGE SLOVAKIA
    When I run Oracle Reports it show perfect in display and when I try to print them, they are all good with good characters, but when I try to generate pdf file, some characters like č,š,ľ are not displaying corectly... This happen only when try to generate to pdf...
    I try to work with uifont.ali on client side but without any result. Fonts for reports were installed on client and server side... Can someone help me with this problem? Thank you very much for every advice.
    Martin

    Hi Sergiusz,
    Thank you for your reply. I look at what you wrote and try to make some test...
    1) For first I download FontForge, which can generate type1 font from true type. So I open FontForge and open my Arial.ttf font and use "Generate Fonts" to save my Arial.ttf font to pfb and pfm (whoch are need to set in uifont.ali). I have to change encoding, because my font has 2byte encoding so I reecondode the font from ISO10646-1 to ISO8859-2 and generate to pfb.
    2) Then I navigate REPORTS_PATH from regedit to my *.pfm and *.pfb files.
    3) I add these lines to end of my uifont.ali
    [ PDF:Embed ]
    Arial = "Arial.pfm Arial.pfb"
    ArialNarrow = "ArialNarrow.pfm ArialNarrow.pfb"
    4) Then I generate my report but nothing change... I check "Font used" in my pdf file, but there were not my fonts embedded I guess..
    I also try PDF:Subset, but it doesnt change anything... I try PDF aliasing to see if my uifont is working - this work very well, but I dont need to change font...
    Any other advice? Thank you so much to everyone!
    Martin

  • How to run batch file from oracle forms 9i

    Hi everyone.
    i have a data in csv file. i want to upload it to my database. i am using sql loader for it.
    i have made a batch file which run the sql loader and transfer my data to database.
    How to run batch file from oracle forms 9i.
    when i press the button, nothing uploads in my database. (when i simply run the batch file it works).
    here is my code
    Begin
    HOST('C:\temp\batchfile.bat');
    message('done');
    end;
    Thanks in advance
    regards
    sajid

    this is my log file, when i run manually.
    SQL*Loader: Release 10.2.0.1.0 - Production on Thu Jul 1 23:27:53 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Control File: file_to_upload.ctl
    There are 2 data files:
    Data File: sk.csv
    Bad File: sk.bad
    Discard File: none specified
    (Allow all discards)
    Data File: sk1.csv
    Bad File: sk1.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    Table KHAN, loaded from every logical record.
    Insert option in effect for this table: APPEND
    Column Name Position Len Term Encl Datatype
    SR FIRST * , O(") CHARACTER
    DATES NEXT * , O(") CHARACTER
    AGENT NEXT * , O(") CHARACTER
    COUNTRY NEXT * , O(") CHARACTER
    TRANSACTIONS NEXT * , O(") CHARACTER
    PKR NEXT * , O(") CHARACTER
    USD NEXT * , O(") CHARACTER
    BANK NEXT * , O(") CHARACTER
    Table KHAN:
    11088 Rows successfully loaded.
    0 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Space allocated for bind array: 132096 bytes(64 rows)
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 11088
    Total logical records rejected: 0
    Total logical records discarded: 0
    Run began on Thu Jul 01 23:27:53 2010
    Run ended on Thu Jul 01 23:27:54 2010
    Elapsed time was: 00:00:00.63
    CPU time was: 00:00:00.17

  • How to create xml file from Oracle and sending the same xml file to an url

    How to create xml file from Oracle and sending the same xml file to an url

    SQL/XML (XMLElement, XMLForest, XMLAgg, etc) and UTL_HTTP.
    Whether that works for you with the version of Oracle you have, your requirements, and needs is another story. A little detail goes a long way.

  • How to I convert data from oracle database into excel sheet

    how to I convert data from oracle database into excel sheet.
    I need to import columns and there datas from oracle database to microsoft excel sheet.
    Please let me know the different ways for doing this.
    Thanks.

    asktom.oracle.com has an excellent article on writing a PL/SQL procedure that dumps data to an Excel spreadsheet-- search for 'Excel' and it'll come up.
    You can also use your favorite connection protocol (ODBC, OLE DB, etc) to connect from Excel to Oracle and pull the data out that way.
    Justin

Maybe you are looking for

  • Printer Setup for HTML reports (Landscape)

    I'm trying to print an HTML report in Landscape, the Report Orientation VI only works with Standard Reports, and I can't find anything that will let me modify the "Printer Setup" Anyone done this?

  • How can I set a value in a field before create when a New button is clicked

    Hi, I am using JDeveloper 10.1.3.1.0.3984 and JHeadstart 10.1.3.1 release 10.1.3.1.26 I have one group and there is a detail group under that group. From main group to detail group there are 3 field relating those groups. field1 field2 fieldSEQ (auto

  • Trying to repair my MBP (early 2008)

    A couple months back my early 2008 model MacBook Pro 15" (A1260) died on me. I hit the power button, the fans flick on for one second and then turn off, the screen remains black, and all other internals seem to be off. The led on the front fades in a

  • XML TEAM - SUGGESTIONS PLEASE

    HI, I am using oracle 8i, oas and windows nt envrionment. I downloaded Plsxml demo files from OTN. I copied all files to my webserver which is using plsql cartridge.I am getting this problem when sample htm files were invoked from browser( ie5.0). Er

  • Import songs from iPod to iTunes?

    I was wondering if there is a way to transfer the songs on my iPod onto my computer bc my last computer crashed and took all my songs with it.