Search in sources :

Example 1 with BinaryTempFileMessageBody

use of com.fsck.k9.mail.internet.BinaryTempFileMessageBody in project k-9 by k9mail.

the class MessageTest method nestedMessage.

private MimeMessage nestedMessage(MimeMessage subMessage) throws MessagingException, IOException {
    BinaryTempFileMessageBody tempMessageBody = new BinaryTempFileMessageBody(MimeUtil.ENC_8BIT);
    OutputStream out = tempMessageBody.getOutputStream();
    try {
        subMessage.writeTo(out);
    } finally {
        out.close();
    }
    MimeBodyPart bodyPart = new MimeBodyPart(tempMessageBody, "message/rfc822");
    bodyPart.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment");
    bodyPart.setEncoding(MimeUtil.ENC_7BIT);
    MimeMessage parentMessage = sampleMessage();
    ((Multipart) parentMessage.getBody()).addBodyPart(bodyPart);
    return parentMessage;
}
Also used : MimeMultipart(com.fsck.k9.mail.internet.MimeMultipart) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) BinaryTempFileMessageBody(com.fsck.k9.mail.internet.BinaryTempFileMessageBody) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart)

Aggregations

BinaryTempFileMessageBody (com.fsck.k9.mail.internet.BinaryTempFileMessageBody)1 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)1 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)1 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1