class ExtractMDNOriginalJMAPMessageId extends GenericMailet {

    @VisibleForTesting Optional<Entity> extractReport(Message message) {
        LOGGER.debug("Extracting report");
        if (!message.isMultipart()) {
            LOGGER.debug("MDN Message must be multipart");
            return Optional.empty();
        }
        List<Entity> bodyParts = ((Multipart) message.getBody()).getBodyParts();
        if (bodyParts.size() < 2) {
            LOGGER.debug("MDN Message must contain at least two parts");
            return Optional.empty();
        }
        Entity report = bodyParts.get(1);
        if (!isDispositionNotification(report)) {
            LOGGER.debug("MDN Message second part must be of type " + MESSAGE_DISPOSITION_NOTIFICATION);
            return Optional.empty();
        }
        return Optional.of(report);
    }

    @Inject public  ExtractMDNOriginalJMAPMessageId(MailboxManager mailboxManager, UsersRepository usersRepository);

}