Send an E-Mail with attachment using JAVA Mail API without storing in local machine

后端 未结 3 1838
时光取名叫无心
时光取名叫无心 2020-12-06 17:29

I have report in my jsp page and I am writing that report in PDF Format. And I want to send the PDF as E-Mail with attachment, but I don\'t want store the file

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 17:55

    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.

提交回复
热议问题