tags:

views:

60

answers:

1

I have a byte array wich i wish to add as an attachement to an email i am sending.

Unfortunally i can't find how to attach it as a byte array, the solution i have uses disk files (which i dont want since i dont want to write the byte array just so i can attach it).

I've found one solution that involves creating an object that extends DataSource and use this as a wrapper for the byte array and then feed that to the MimeBodyPart.

Anyone know of a better solution?

+2  A: 

Creating a DataSource is the right approach. You don't have to write your own, though. Just use the ByteArrayDataSource from JavaMail.

erickson
/facepalm i dont know why i didnt see that class, especially considering i was trying to use the other solution and i wrote the class down and named it : ByteArrayDatasource. =S
Nuno Furtado