Skip to content

Commit

Permalink
#10: add support for both short and long filename for embedded images…
Browse files Browse the repository at this point in the history
…, depending on which one was used in the HTML
  • Loading branch information
bbottema committed Sep 29, 2019
1 parent 00d4fa5 commit 56a1764
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,23 @@ public Map<String, OutlookFileAttachment> fetchCIDMap() {
for (final OutlookAttachment attachment : getOutlookAttachments()) {
if (attachment instanceof OutlookFileAttachment) {
final OutlookFileAttachment fileAttachment = (OutlookFileAttachment) attachment;
final String cid = fileAttachment.getFilename();
if (cid != null && cid.length() != 0 && htmlContainsCID(html, cid)) {
cidMap.put(cid, fileAttachment);
if (!tryAddCid(cidMap, html, fileAttachment, fileAttachment.getFilename())) {
tryAddCid(cidMap, html, fileAttachment, fileAttachment.getLongFilename());
}
}
}
}
return cidMap;
}


private boolean tryAddCid(HashMap<String, OutlookFileAttachment> cidMap, String html, OutlookFileAttachment a, String cid) {
final boolean cidFound = cid != null && cid.length() != 0 && htmlContainsCID(html, cid);
if (cidFound) {
cidMap.put(cid, a);
}
return cidFound;
}

/**
* @return Only the downloadable attachments, *not* embedded attachments (as in embedded with cid:attachment, such as images in an email). This includes
* downloadable nested outlook messages as file attachments!
Expand Down

0 comments on commit 56a1764

Please sign in to comment.