List of usage examples for org.apache.commons.mail HtmlEmail embed
public String embed(final DataSource dataSource, final String name) throws EmailException
DataSource
in the HTML using a randomly generated Content-ID. From source file:org.ploin.pmf.impl.MailSender.java
/** * * @param email - the email object//from w w w . jav a 2 s.c o m * @param map - the map with the values and variables * @param mail - the mail as string */ private void setEmbeds(HtmlEmail email, Map<String, String> map, String mail) throws MailFactoryException { try { for (String key : map.keySet()) { if (key.startsWith("embed")) { URL url = null; String urlString = map.get(key); url = new URL(urlString); if (url != null) { String cid = email.embed(url, key); String htmlVal = "cid:" + cid; mail = mail.replaceAll(key, htmlVal); } } } } catch (Exception e) { throw new MailFactoryException(e); } }