in commons-email2-jakarta/src/main/java/org/apache/commons/mail2/jakarta/util/MimeMessageUtils.java [119:127]
public static void writeMimeMessage(final MimeMessage mimeMessage, final File resultFile) throws MessagingException, IOException {
if (!resultFile.getParentFile().exists() && !resultFile.getParentFile().mkdirs()) {
throw new IOException("Failed to create the following parent directories: " + resultFile.getParentFile());
}
try (OutputStream outputStream = new FileOutputStream(resultFile)) {
mimeMessage.writeTo(outputStream);
outputStream.flush();
}
}