in commons-email2-javax/src/main/java/org/apache/commons/mail2/javax/HtmlEmail.java [332:347]
public String embed(final DataSource dataSource, final String name, final String cid) throws EmailException {
EmailException.checkNonEmpty(name, () -> "Name cannot be null or empty");
final MimeBodyPart mbp = new MimeBodyPart();
try {
// URL encode the cid according to RFC 2392
final String encodedCid = EmailUtils.encodeUrl(cid);
mbp.setDataHandler(new DataHandler(dataSource));
mbp.setFileName(name);
mbp.setDisposition(EmailAttachment.INLINE);
mbp.setContentID("<" + encodedCid + ">");
this.inlineEmbeds.put(name, new InlineImage(encodedCid, dataSource, mbp));
return encodedCid;
} catch (final MessagingException e) {
throw new EmailException(e);
}
}