code: private static MimeBodyPart createBodyPart(byte[] data, String type, String filename) throws MessagingException {
          final MimeBodyPart attachmentPart = new MimeBodyPart();
          attachmentPart.setFileName(filename);
          ByteArrayDataSource source = new ByteArrayDataSource(data, type);
          attachmentPart.setDataHandler(new DataHandler(source));
          attachmentPart.setHeader("Content-ID", createContentID(filename));
          attachmentPart.setDisposition(MimeBodyPart.INLINE);
          return attachmentPart;
      }
docs: Build attachment part