class ICSSanitizer extends GenericMailet {

    @Override
    public void service(Mail mail) {
        try {
            MimeMessage mimeMessage = mail.getMessage();

            if (mimeMessage.getContent() instanceof Multipart) {
                Multipart multipart = (Multipart) mimeMessage.getContent();

                if (needsSanitizing(multipart)) {
                    mimeMessage.setContent(sanitize(multipart));
                    mimeMessage.saveChanges();
                }
            }
        } catch (Exception e) {
            LOGGER.warn("Could not sanitize {}", mail.getName(), e);
        }
    }

}