how to email csv file using UTL_MAIL and select statement

I want to select * from emp and then email the data as a csv file using UTL_MAIL.  How?  Thanks.
ewang1205Asked:
Who is Participating?
 
sdstuberConnect With a Mentor Commented:
you can use utl_mail for attachments up to 32K

if you need more than that you must use utl_smtp


Here's an example with code I wrote that generates a csv and emails it including the mime encoding needed to create the attachment

http://www.experts-exchange.com/Q_26388878.html
0
 
slightwv (䄆 Netminder)Connect With a Mentor Commented:
What part?

There are tons of examples creating a csv in Oracle.  I prefer the XMLAGG method.

Using that, select the csv into a varchar2 variable.  Then add that to the message call in utl_mail.

There are tons of utl_mail examples as well.

Just make a note: utl_mail is limited to 32K for a message body.
0
 
ewang1205Author Commented:
The content may be over 32k.  So utl_mail limit 32k for attachment??  
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
slightwv (䄆 Netminder) Commented:
I'm not sure utl_mail even does attachments.  It's a pretty dumbed down utility.

You will need to use utl_smtp and 'roll your own'.  The good news, there are also tons of examples sending emails with attachments using utl_smtp out there as well.

Google around and pick the one you like best.  They are out there.
0
 
slightwv (䄆 Netminder) Commented:
And, the xmlagg method of creating a csv returns a clob.  That gives you up to 4 Gig.
0
 
ewang1205Author Commented:
ok, I am checking utl_smtp now...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.