code: private BodyPart handleMultiPart(Multipart body) throws IOException, MessagingException {
          BodyPart bodyPart = null;
          for (int i = 0; i < body.getCount(); i++) {
              MimePart entity = (MimePart) body.getBodyPart(i);
  
              if (bodyPart == null) {
                  bodyPart = handlePart(entity);
              } else {
                  BodyPart attachment = handlePart(entity);
                  bodyPart.addPart(new AttachmentPart(attachment.getContent(), parseContentType(attachment.getContentType()), entity.getFileName()));
              }
          }
  
          return bodyPart;
      }
docs: Construct multipart body with first part being the body content and further parts being the attachments.
  @param body
  @return
  @throws IOException