Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> Send mail with attachment

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Send mail with attachment
 Priya  Posted: Apr 03, 2008 05:35:23 AM

 Total Post: 19
 Joined: Jul, 2007






 Hi All,

Actually, i need to send a mail with attachment using PL/SQL code.
That attachment file is located in Server directory.
Please let me know how to proceed with UTL_FILE and UTL_SMTP.

Thanks in advance.

Regards,
Priya.V

 Murtuja
Posted: Apr 03, 2008 05:41:25 AM  

 Total Post: 857
 Joined: Jan, 2006






 
Hi

http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html

HTH

 Priya
Posted: Apr 03, 2008 05:46:44 AM  

 Total Post: 19
 Joined: Jul, 2007






 
Hi Murtuja,

I tried that code. But when it sends the attachment, it is blank. Please let me know how to set the path for the File in server directory.

Thanks,

Priya.V

 Murtuja
Posted: Apr 03, 2008 05:46:56 AM  

 Total Post: 857
 Joined: Jan, 2006






 
Another method of sending attachments using Java stored procedure

http://asktom.oracle.com/pls/asktom/f?p=100:11:2331967589925392::::P11_QUESTION_ID:255615160805

 Priya
Posted: Apr 03, 2008 05:49:08 AM  

 Total Post: 19
 Joined: Jul, 2007






 
Hi,

I want to send it using PL/SQL Procedure only. Please help.

My requirements are,

The Output of my query should be stored in an Excel file in the server.

That excel file should be sent as an attachement.

Please help.

Regards,

Priya

 Mohammed Taj
Posted: Apr 03, 2008 11:54:47 AM  

 Total Post: 746
 Joined: Jul, 2007






 
Did you try with this
http://www.orafaq.com/wiki/Send_mail_from_PL/SQL

 Mohammed Taj
Posted: Apr 03, 2008 11:57:27 AM  

 Total Post: 746
 Joined: Jul, 2007






 
Check this also
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:503989273966

 narendra
Posted: Apr 10, 2008 01:11:40 AM  

 Total Post: 1
 Joined: Mar, 2008






 
Priya,

i think u r using content encoding as "Content-Transfer-Encoding: 7bit" this will work for text file, while to attach file like excel, doc etc u need to use
1.encoding "Content-Transfer-Encoding: base64"
e.g mesg := mesg || 'Content-Type: ' || filetype ||
'; name="' || file_name || '"' || crlf ||
'Content-Disposition: attachment; filename="' ||
file_name || '"' || crlf ||
'Content-Transfer-Encoding: base64' || crlf || crlf ;

2. open your attachment as bfile and read through dbms_lob
e.g bfile_handle := BFILENAME(directory_name,file_name);
dbms_lob.READ(bfile_handle,read_bytes,pos,Data);
3. write the lob content into message using utl_smtp.write_raw_data
e.g. utl_smtp.write_raw_data(conn,utl_encode.base64_encode(Data));

this work for me. I hope this will work for u too.


 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik387
  Vinoth Kumar379
  Gopu Gopi350
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software