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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) 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
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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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
sdstuberCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.