Skip to content
Advertisement

java mail as pdf files as attachment

I am trying to send an e-mail with a PDF as an attachment. It was including the file but its size was less than what it was on disk, and when trying to open it, it says the file is corrupted.

JavaScript

Advertisement

Answer

Doing some research i found another topic about sending mail with pdf attachment here.

He does it by stream but i think that is what you need.

JavaScript

You have to write your own implementation of javax.activation.DataSource to read the attachment data from an memory instead of using one of the included implementations (to read from a file, a URL, etc.). If you have the PDF report in a byte array, you can implement a DataSource which returns the byte array wrapped in a ByteArrayOutputStream. source

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement