commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject Re: [email] ImageHtmlEmail and base64 encoded image in html body throws exception
Date Wed, 06 Dec 2017 14:51:21 GMT

DataSourceUrlResolver image argument needs to be a URL (not null and not a plain String)

DataSourceUrlResolver(final URL baseUrl)

From: Raffaele Gambelli <>
Sent: Wednesday, December 6, 2017 8:19 AM
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

base64 testing image - JSFiddle<>
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: unknown protocol: data
        at org.apache.commons.mail.resolver.DataSourceUrlResolver.createUrl(

I'm going to parse the html, finding those encoded img, decoding them to obtain file and embedding
it as suggested int he guide
Commons Email – Examples<>
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:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message