File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes how to send files stored as blob in mysql as attachment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "how to send files stored as blob in mysql as attachment" Watch "how to send files stored as blob in mysql as attachment" New topic
Author

how to send files stored as blob in mysql as attachment

Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Hey guys,thanks for your attention.

Here is my question:

Now,in my website I can upload some files into MYSQL DB,and I want to select some of these files as attachment to be sent to customer.
I know it is very easy if the file is stored as a file in a particular directory,what i need is to get the path of the file and then use a javamail function "attachFile(path)",how can i do it when the file is stored as blob?Is there any javamail function which can be used to manipulate this process?


truehh@hotmail.com
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Moving to Other Java APIs where the Javamail gurus hang out.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Read the BLOB into a byte array in your program. Then use a ByteArrayDataSource to attach it to the message.
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Thanks,I will test it on next monday.
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
It works pretty good.Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to send files stored as blob in mysql as attachment