Skip to content

Instantly share code, notes, and snippets.

@rgambelli
rgambelli / gist:099b48a513bb4f8f4a30d63cb662eaa1
Created December 11, 2017 09:05
Find data:image in email html body, decode, embed and replacing them with <img src="cid:...", return the new html body
private String replaceImgPattern(ImageHtmlEmail imageHtmlEmail, String html) {
Matcher matcher = IMG_PATTERN.matcher(html);
// Used to name the embedded images
int i = 0;
while (matcher.find()) {
// in the RegEx we have the <src> element as second "group"
String srcAttribute = matcher.group(2);