DataSourceUrlResolver image argument needs to be a URL (not null and not a plain String)
DataSourceUrlResolver(final URL baseUrl) M- ________________________________ From: Raffaele Gambelli <[email protected]> Sent: Wednesday, December 6, 2017 8:19 AM To: [email protected] Subject: [email] ImageHtmlEmail and base64 encoded image in html body throws exception Hi all, I would like to send emails with some given html, sometimes my html contains base64 encoded images, I mean images like this https://jsfiddle.net/casiano/xadvz/ [https://assets.servedby-buysellads.com/p/manage/asset/id/32052]<https://jsfiddle.net/casiano/xadvz/> base64 testing image - JSFiddle<https://jsfiddle.net/casiano/xadvz/> jsfiddle.net Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor. <img src="data:image/gif;base64,R0.................................................. I'm using commons email 1.4 and when I send that html, using email.setDataSourceResolver(new DataSourceUrlResolver(null));, I receive this: Caused by: java.net.MalformedURLException: unknown protocol: data at java.net.URL.<init>(URL.java:600) at java.net.URL.<init>(URL.java:490) at java.net.URL.<init>(URL.java:439) at org.apache.commons.mail.resolver.DataSourceUrlResolver.createUrl(DataSourceUrlResolver.java:115) I'm going to parse the html, finding those encoded img, decoding them to obtain file and embedding it as suggested int he guide https://commons.apache.org/proper/commons-email/userguide.html. Commons Email – Examples<https://commons.apache.org/proper/commons-email/userguide.html> commons.apache.org A simple text email. Our first example will create a basic email message to "John Doe" and send it through your Google Mail (GMail) account. Nevertheless it seems strange that commons email is not able to handle with those inline images that are quite common in signatures, am I wrong? Thanks and best regards Raffaele Gambelli --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
