added inline attachments flag to set Content-Type to multipart/related as needed

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@27 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2007-02-08 17:02:45 +00:00
parent e195a5f5c8
commit bcc1067b89
1 changed files with 7 additions and 2 deletions

View File

@ -584,6 +584,7 @@ public class ExchangeSession {
public String htmlBody; public String htmlBody;
public String contentClass; public String contentClass;
public boolean hasAttachment; public boolean hasAttachment;
public boolean hasInlineAttachment;
public String to; public String to;
public String cc; public String cc;
public String date; public String date;
@ -660,11 +661,12 @@ public class ExchangeSession {
// patch exchange Content type // patch exchange Content type
if (line.equals(CONTENT_TYPE_HEADER + "application/ms-tnef;")) { if (line.equals(CONTENT_TYPE_HEADER + "application/ms-tnef;")) {
if (hasAttachment) { if (hasAttachment) {
// trigger attachments load
loadAttachments();
boundary = "----_=_NextPart_001_" + uid; boundary = "----_=_NextPart_001_" + uid;
String contentType = "multipart/mixed"; String contentType = "multipart/mixed";
// use multipart/related with inline images // use multipart/related with inline images
if (htmlBody != null && (htmlBody.indexOf("src=\"cid:") > 0 || if (hasInlineAttachment) {
htmlBody.indexOf("src=\"1_multipart") > 0)) {
contentType = "multipart/related"; contentType = "multipart/related";
} }
line = CONTENT_TYPE_HEADER + contentType + ";\n\tboundary=\"" + boundary + "\""; line = CONTENT_TYPE_HEADER + contentType + ";\n\tboundary=\"" + boundary + "\"";
@ -1149,6 +1151,9 @@ public class ExchangeSession {
} }
} }
// set inline attachments flag
hasInlineAttachment = (htmlBodyImgList.size() > 0);
// use owa generated body to look for inline images // use owa generated body to look for inline images
List<Attribute> imgList = xmlDocument.getNodes("//img/@src"); List<Attribute> imgList = xmlDocument.getNodes("//img/@src");