Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use real Outlook ContentId Attribute to resolve CID Attachments #19

Merged
merged 2 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class OutlookFileAttachment implements OutlookAttachment {
* Mime type of the attachment
*/
private String mimeTag;
/**
* CID of the attachment
*/
private String contentId;
/**
* The extension of the attachment (may not be set).
*/
Expand Down Expand Up @@ -58,6 +62,9 @@ public void setProperty(final OutlookMessageProperty msgProp) {
case "3703":
setExtension((String) value);
break;
case "3712":
setContentId((String) value);
break;
default:
// property to ignore, for full list see properties-list.txt
}
Expand Down Expand Up @@ -89,6 +96,21 @@ public String toString() {
return (longFilename != null) ? longFilename : filename;
}

/**
* Bean getter for {@link #contentId}.
*/
@SuppressWarnings("ElementOnlyUsedFromTestCode")
public String getContentId() {
return contentId;
}

/**
* Bean setter for {@link #contentId}.
*/
void setContentId(final String contentId) {
this.contentId = contentId;
}

/**
* Bean getter for {@link #extension}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,10 @@ public Map<String, OutlookFileAttachment> fetchCIDMap() {
for (final OutlookAttachment attachment : getOutlookAttachments()) {
if (attachment instanceof OutlookFileAttachment) {
final OutlookFileAttachment fileAttachment = (OutlookFileAttachment) attachment;
if (!tryAddCid(cidMap, html, fileAttachment, fileAttachment.getFilename())) {
tryAddCid(cidMap, html, fileAttachment, fileAttachment.getLongFilename());
if (!tryAddCid(cidMap, html, fileAttachment, fileAttachment.getContentId())) {
if (!tryAddCid(cidMap, html, fileAttachment, fileAttachment.getFilename())) {
tryAddCid(cidMap, html, fileAttachment, fileAttachment.getLongFilename());
}
}
}
}
Expand Down