in commons-email2-jakarta/src/main/java/org/apache/commons/mail2/jakarta/MultiPartEmail.java [170:187]
public MultiPartEmail attach(final DataSource dataSource, String name, final String description, final String disposition) throws EmailException {
if (EmailUtils.isEmpty(name)) {
name = dataSource.getName();
}
try {
final BodyPart bodyPart = createBodyPart();
bodyPart.setDisposition(disposition);
bodyPart.setFileName(MimeUtility.encodeText(name));
bodyPart.setDescription(description);
bodyPart.setDataHandler(new DataHandler(dataSource));
getContainer().addBodyPart(bodyPart);
} catch (final UnsupportedEncodingException | MessagingException e) {
// in case the file name could not be encoded
throw new EmailException(e);
}
setBoolHasAttachments(true);
return this;
}