1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 11:12:22 -05:00

SMTP: new try at encoding fix: set mailOverrideFormat and messageFormat

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1436 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-09-09 21:22:05 +00:00
parent dc21124beb
commit 356d8afdd2
2 changed files with 21 additions and 7 deletions

View File

@ -2088,6 +2088,9 @@ public class DavExchangeSession extends ExchangeSession {
if (properties != null && properties.containsKey("mailOverrideFormat")) {
davProperties.add(Field.createDavProperty("mailOverrideFormat", properties.get("mailOverrideFormat")));
}
if (properties != null && properties.containsKey("messageFormat")) {
davProperties.add(Field.createDavProperty("messageFormat", properties.get("messageFormat")));
}
if (!davProperties.isEmpty()) {
patchMethod = new PropPatchMethod(messageUrl, davProperties);
try {
@ -2202,6 +2205,16 @@ public class DavExchangeSession extends ExchangeSession {
}
}
public static final long MAPI_SEND_NO_RICH_INFO = 0x00010000L;
public static final long ENCODING_PREFERENCE = 0x00020000L;
public static final long ENCODING_MIME = 0x00040000L;
public static final long BODY_ENCODING_HTML = 0x00080000L;
public static final long BODY_ENCODING_TEXT_AND_HTML = 0x00100000L;
public static final long MAC_ATTACH_ENCODING_UUENCODE = 0x00200000L;
public static final long MAC_ATTACH_ENCODING_APPLESINGLE = 0x00400000L;
public static final long MAC_ATTACH_ENCODING_APPLEDOUBLE = 0x00600000L;
public static final long OOP_DONT_LOOKUP = 0x10000000L;
@Override
public void sendMessage(MimeMessage mimeMessage) throws IOException {
try {
@ -2211,9 +2224,10 @@ public class DavExchangeSession extends ExchangeSession {
properties.put("draft", "9");
String contentType = mimeMessage.getContentType();
if (contentType != null && contentType.startsWith("text/plain")) {
properties.put("mailOverrideFormat", "2");
properties.put("messageFormat", "1");
} else {
properties.put("mailOverrideFormat", "1");
properties.put("mailOverrideFormat", String.valueOf(ENCODING_PREFERENCE | ENCODING_MIME | BODY_ENCODING_TEXT_AND_HTML));
properties.put("messageFormat", "2");
}
createMessage(DRAFTS, itemName, properties, mimeMessage);
moveItem(DRAFTS + '/' + itemName, SENDMSG);

View File

@ -112,6 +112,9 @@ public class TestSmtp extends AbstractDavMailTestCase {
}
public void sendAndCheckMessage(MimeMessage mimeMessage, String from, String bcc) throws IOException, MessagingException, InterruptedException {
// copy Message-id to references header
mimeMessage.writeTo(System.out);
mimeMessage.addHeader("references", mimeMessage.getHeader("message-id")[0]);
if (from != null) {
writeLine("MAIL FROM:" + from);
} else {
@ -133,7 +136,7 @@ public class TestSmtp extends AbstractDavMailTestCase {
// wait for asynchronous message send
ExchangeSession.MessageList messages = null;
for (int i = 0; i < 5; i++) {
messages = session.searchMessages("Sent", session.headerIsEqualTo("message-id", mimeMessage.getMessageID()));
messages = session.searchMessages("Sent", session.headerIsEqualTo("references", mimeMessage.getMessageID()));
if (messages.size() > 0) {
break;
}
@ -142,10 +145,7 @@ public class TestSmtp extends AbstractDavMailTestCase {
assertEquals(1, messages.size());
ExchangeSession.Message sentMessage = messages.get(0);
sentMessage.getMimeMessage().writeTo(System.out);
// message is converted to html over Dav
if (Settings.getBooleanProperty("davmail.enableEws")) {
assertEquals(mimeMessage.getDataHandler().getContent(), sentMessage.getMimeMessage().getDataHandler().getContent());
}
assertEquals(mimeMessage.getDataHandler().getContent(), sentMessage.getMimeMessage().getDataHandler().getContent());
}
public void testSendSimpleMessage() throws IOException, MessagingException, InterruptedException {