1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-11-12 04:15:08 -05:00

IMAP: Fix 3383832, set ItemClass to send read receipt over EWS to avoid ErrorObjectTypeChanged

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1762 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-08-05 20:05:58 +00:00
parent 0b5a22f63f
commit 4bc0773aa7
4 changed files with 25 additions and 23 deletions

View File

@ -658,14 +658,6 @@ public abstract class ExchangeSession {
*/ */
public abstract void deleteMessage(Message message) throws IOException; public abstract void deleteMessage(Message message) throws IOException;
/**
* Send message.
*
* @param messageBody MIME message body
* @throws IOException on error
*/
public abstract void sendMessage(byte[] messageBody) throws IOException;
/** /**
* Get raw MIME message content * Get raw MIME message content
* *
@ -1236,7 +1228,7 @@ public abstract class ExchangeSession {
* @param mimeMessage MIME message * @param mimeMessage MIME message
* @throws IOException on error * @throws IOException on error
*/ */
public abstract void sendMessage(MimeMessage mimeMessage) throws IOException; public abstract void sendMessage(MimeMessage mimeMessage) throws IOException, MessagingException;
/** /**
* Get folder object. * Get folder object.
@ -2224,9 +2216,9 @@ public abstract class ExchangeSession {
protected byte[] getICS(InputStream mimeInputStream) throws IOException, MessagingException { protected byte[] getICS(InputStream mimeInputStream) throws IOException, MessagingException {
byte[] result; byte[] result;
MimeMessage mimeMessage = new MimeMessage(null, mimeInputStream); MimeMessage mimeMessage = new MimeMessage(null, mimeInputStream);
String[] contentClass = mimeMessage.getHeader("Content-class"); String[] contentClassHeader = mimeMessage.getHeader("Content-class");
// task item, return null // task item, return null
if (contentClass != null && contentClass.length > 0 && "urn:content-classes:task".equals(contentClass[0])) { if (contentClassHeader != null && contentClassHeader.length > 0 && "urn:content-classes:task".equals(contentClassHeader[0])) {
return null; return null;
} }
Object mimeBody = mimeMessage.getContent(); Object mimeBody = mimeMessage.getContent();

View File

@ -2490,9 +2490,11 @@ public class DavExchangeSession extends ExchangeSession {
} }
/** /**
* @inheritDoc * Send message.
*
* @param messageBody MIME message body
* @throws IOException on error
*/ */
@Override
public void sendMessage(byte[] messageBody) throws IOException { public void sendMessage(byte[] messageBody) throws IOException {
try { try {
sendMessage(new MimeMessage(null, new SharedByteArrayInputStream(messageBody))); sendMessage(new MimeMessage(null, new SharedByteArrayInputStream(messageBody)));

View File

@ -500,6 +500,11 @@ public abstract class EWSMethod extends PostMethod {
writer.write("<t:"); writer.write("<t:");
writer.write(type); writer.write(type);
writer.write(">"); writer.write(">");
if (mimeContent != null) {
writer.write("<t:MimeContent>");
writer.write(new String(mimeContent));
writer.write("</t:MimeContent>");
}
// write ordered fields // write ordered fields
for (String key : fieldNames) { for (String key : fieldNames) {
if ("MeetingTimeZone".equals(key)) { if ("MeetingTimeZone".equals(key)) {
@ -520,11 +525,6 @@ public abstract class EWSMethod extends PostMethod {
writer.write(">"); writer.write(">");
} }
} }
if (mimeContent != null) {
writer.write("<t:MimeContent>");
writer.write(new String(mimeContent));
writer.write("</t:MimeContent>");
}
if (fieldUpdates != null) { if (fieldUpdates != null) {
for (FieldUpdate fieldUpdate : fieldUpdates) { for (FieldUpdate fieldUpdate : fieldUpdates) {
fieldUpdate.write(null, writer); fieldUpdate.write(null, writer);

View File

@ -440,11 +440,14 @@ public class EwsExchangeSession extends ExchangeSession {
executeMethod(deleteItemMethod); executeMethod(deleteItemMethod);
} }
@Override
public void sendMessage(byte[] messageBody) throws IOException { public void sendMessage(String itemClass, byte[] messageBody) throws IOException {
EWSMethod.Item item = new EWSMethod.Item(); EWSMethod.Item item = new EWSMethod.Item();
item.type = "Message"; item.type = "Message";
item.mimeContent = Base64.encodeBase64(messageBody); item.mimeContent = Base64.encodeBase64(messageBody);
if (itemClass != null) {
item.put("ItemClass", itemClass);
}
MessageDisposition messageDisposition; MessageDisposition messageDisposition;
if (Settings.getBooleanProperty("davmail.smtpSaveInSent", true)) { if (Settings.getBooleanProperty("davmail.smtpSaveInSent", true)) {
@ -458,14 +461,19 @@ public class EwsExchangeSession extends ExchangeSession {
} }
@Override @Override
public void sendMessage(MimeMessage mimeMessage) throws IOException { public void sendMessage(MimeMessage mimeMessage) throws IOException, MessagingException {
String itemClass = null;
if (mimeMessage.getContentType().startsWith("multipart/report")) {
itemClass = "REPORT.IPM.Note.IPNRN";
}
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
mimeMessage.writeTo(baos); mimeMessage.writeTo(baos);
} catch (MessagingException e) { } catch (MessagingException e) {
throw new IOException(e.getMessage()); throw new IOException(e.getMessage());
} }
sendMessage(baos.toByteArray()); sendMessage(itemClass, baos.toByteArray());
} }
/** /**
@ -1684,7 +1692,7 @@ public class EwsExchangeSession extends ExchangeSession {
// no recipients, cancel // no recipients, cancel
return HttpStatus.SC_NO_CONTENT; return HttpStatus.SC_NO_CONTENT;
} else { } else {
sendMessage(mimeContent); sendMessage(null, mimeContent);
return HttpStatus.SC_OK; return HttpStatus.SC_OK;
} }
} }