Print MIME entities including MIME children


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();
		}
	}
}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...