code: static Map<String,Collection<String>> extractTextParts(Multipart multiPart) throws MessagingException, IOException {
          HashMap<String,Collection<String>> bodies = new HashMap<>();
          for(int i = 0; i < multiPart.getCount(); i++) {
              checkPartForTextType(bodies, multiPart.getBodyPart(i));
          }
          return bodies;
      }
docs: Extract parts from Multi-part message.
  @param multiPart multi-part to visit
  @return map of part contentType -> part content
  @throws MessagingException
  @throws IOException