does java mail API uses streaming? where can i get the source code to confirm this. also i am tryign to send the mail using raw and non-raw mode. in raw mode i can pass an input Stream to MimeMessage constructor:[/b]
new MimeMessage(session, doc.getBodyInputStream());
In Non-raw mode, i have to do the following
Since there can be any mime type, so i have to use DataHandler
and DataSource
. Since the DataSource
interface contracts says of providing the fresh inputStream everytime we invoke getInputStream()
, we need to keep the data in the byte[]
which will throw OOM for large size or documents Is there a way to avoid this?
MimeMessage msg = new MimeMessage(session);
byte[] bArr = doc.getBody();
ByteArrayInputStream ins = new ByteArrayInputStream(
bArr != null && bArr.length > 0 ? bArr : "".getBytes());
msg.setDataHandler(new DataHandler( new ByteArrayDataSource(ins, mimeType)));