private void printMIME(MIMEEntity mime, Stream stream) throws NotesException { if (mime == null) { return; } // Encode binary as baes64 if (mime.getEncoding() == MIMEEntity.ENC_IDENTITY_BINARY) { mime.decodeContent(); mime.encodeContent(MIMEEntity.ENC_BASE64); } stream.writeText(mime.getBoundaryStart()); mime.getEntityAsText(stream); stream.writeText(mime.getBoundaryEnd() + "\n"); if (mime.getContentType().equalsIgnoreCase("multipart")) { // Print preamble if (!mime.getPreamble().isEmpty()) { stream.writeText(mime.getPreamble() + "\n", MIMEEntity.ENC_NONE); } // Print content of each child entity MIMEEntity mimeRootChild = mime.getFirstChildEntity(); while (mimeRootChild != null) { printMIME(mimeRootChild, stream); mimeRootChild = mimeRootChild.getNextSibling(); } } }