mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-08 12:18:07 -05:00
EWS: update createMessage bcc handling to match sendMessage
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1169 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
7a2c4d1998
commit
0d060ca1f0
@ -165,13 +165,15 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
public void createMessage(String folderPath, String messageName, HashMap<String, String> properties, String messageBody) throws IOException {
|
public void createMessage(String folderPath, String messageName, HashMap<String, String> properties, String 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.getBytes());
|
|
||||||
String bcc = properties.get("bcc");
|
String bcc = properties.get("bcc");
|
||||||
// Exchange 2007 is unable to handle bcc field on create
|
|
||||||
//noinspection VariableNotUsedInsideIf
|
|
||||||
if (bcc != null) {
|
if (bcc != null) {
|
||||||
properties.remove("bcc");
|
properties.remove("bcc");
|
||||||
|
// put bcc header back into mime body, Exchange will handle it on send
|
||||||
|
item.mimeContent = Base64.encodeBase64(("bcc: "+bcc+ "\r\n" +messageBody).getBytes());
|
||||||
|
} else {
|
||||||
|
item.mimeContent = Base64.encodeBase64(messageBody.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<FieldUpdate> fieldUpdates = buildProperties(properties);
|
Set<FieldUpdate> fieldUpdates = buildProperties(properties);
|
||||||
if (!properties.containsKey("draft")) {
|
if (!properties.containsKey("draft")) {
|
||||||
// need to force draft flag to false
|
// need to force draft flag to false
|
||||||
@ -184,18 +186,6 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
item.setFieldUpdates(fieldUpdates);
|
item.setFieldUpdates(fieldUpdates);
|
||||||
CreateItemMethod createItemMethod = new CreateItemMethod(MessageDisposition.SaveOnly, getFolderId(folderPath), item);
|
CreateItemMethod createItemMethod = new CreateItemMethod(MessageDisposition.SaveOnly, getFolderId(folderPath), item);
|
||||||
executeMethod(createItemMethod);
|
executeMethod(createItemMethod);
|
||||||
|
|
||||||
if (bcc != null) {
|
|
||||||
ItemId itemId = new ItemId(createItemMethod.getResponseItem());
|
|
||||||
HashMap<String, String> localProperties = new HashMap<String, String>();
|
|
||||||
localProperties.put("bcc", bcc);
|
|
||||||
UpdateItemMethod updateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly,
|
|
||||||
ConflictResolution.AlwaysOverwrite,
|
|
||||||
SendMeetingInvitationsOrCancellations.SendToNone,
|
|
||||||
itemId, buildProperties(localProperties));
|
|
||||||
executeMethod(updateItemMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,7 +128,8 @@ public class TestImap extends AbstractDavMailTestCase {
|
|||||||
public void testCreateMessage() throws IOException, MessagingException {
|
public void testCreateMessage() throws IOException, MessagingException {
|
||||||
|
|
||||||
MimeMessage mimeMessage = new MimeMessage((Session) null);
|
MimeMessage mimeMessage = new MimeMessage((Session) null);
|
||||||
mimeMessage.addHeader("To", "test@test.local");
|
mimeMessage.addHeader("to", Settings.getProperty("davmail.to"));
|
||||||
|
mimeMessage.addHeader("bcc", Settings.getProperty("davmail.bcc"));
|
||||||
mimeMessage.setText("Test message");
|
mimeMessage.setText("Test message");
|
||||||
mimeMessage.setSubject("Test subject");
|
mimeMessage.setSubject("Test subject");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
Loading…
Reference in New Issue
Block a user