Announcement Announcement Module
Collapse
No announcement yet.
Mail attachment streaming Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mail attachment streaming

    Hi

    I want to send emails with generated attachments. Attachements may be quite big so I dont want to hold them entirely in memory (i.e byte[]).What I want to achieve is to write them to some output stream (in the same way I write to ServletOutputStream). The problem is with Spring Mail API. I found only MimeMessageHelper.addAttachment(String, InputStreamSource). I know that it is possible to write my own InputStream implementation and generate some part of attachment every time one of read() method is called, but I think is quite hard, uneffective and not elegant. What Im looking for is some callback interface (or any other mechanism working with OutputStram) with method like this one:

    Code:
    public void writeAttachment(OutputStream outputStream);
    I don't know Java Mail API well so it may be impossible, but whant to know what are you thinking about such solution ?
    Is there any other solution (simplier then writing my own InputStream) to stream attachments ?

    Regards
    Daniel
Working...
X