class MessagePartCreators {

    public static void addAllPartsTo(final SMTPMessageAdaptor smtpMessage, final IObject context, final List<IObject> parts) throws Exception {
        for (IObject part : parts) {
            try {
                creatorsMap
                        .get(partType_Part_F.in(part))
                        .addPartTo(smtpMessage, context, part);
            } catch (NullPointerException e) {
                throw new PartCreatorException("Part type not found.", e);
            } catch (ChangeValueException | ReadValueException | MessagingException e) {
                throw new PartCreatorException("Failed to create message part.", e);
            } catch (InvalidArgumentException e) {
                throw new Exception("Failed to extract type", e);
            }
        }
    }

}