• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Mail File Attatchment  RSS feed

 
Patrick McDonogh
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There All,

I am trying to attatch a file to an email.

The trick is that the file does not exist on the file system. I have an InputStream which can read the file, as the file is stored as a blob in the database.

Does anyone know how to attatch a file to an email using an input stream.

I would prefer not to have to write the file to the file system and then create a File object from the file and then attatch this to the email as this would add additional overhead.

Cheers for any help guys and girls,

Patrick
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you downloaded JavaMail 1.3 then look in the "demo" directory. You'll find a ByteArrayDataSource class that allows you to make an attachment from an array of bytes. (If you are using JavaMail 1.4 then that class is now part of the standard API.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!