commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raffaele Gambelli <R.Gambe...@hitachi-systems-cbt.com>
Subject Re: [email] ImageHtmlEmail and base64 encoded image in html body throws exception
Date Wed, 06 Dec 2017 15:43:20 GMT
Hi Martin,

do you think that applying what you said resolves the exception Caused by: java.net.MalformedURLException:
unknown protocol: data ?
I think not...

Anyway thanks for your precision but passing null to DataSourceUrlResolver works perfectly
for "src" like http://www.apache.org/images/asf_logo_wide.gif

regards

Raffaele Gambelli



-----Martin Gainty <mgainty@hotmail.com> ha scritto: -----
Per: Commons Users List <user@commons.apache.org>
Da: Martin Gainty <mgainty@hotmail.com>
Data: 06/12/2017 03.52PM
Oggetto: Re: [email] ImageHtmlEmail and base64 encoded image in html body throws exception

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



DataSourceUrlResolver(final URL baseUrl)

M-
________________________________
From: Raffaele Gambelli <R.Gambelli@hitachi-systems-cbt.com>
Sent: Wednesday, December 6, 2017 8:19 AM
To: user@commons.apache.org
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 &#8211; 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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message